private void HandlePostIndexChangedRequest(NamedPipeMessages.Message message, NamedPipeServer.Connection connection) { NamedPipeMessages.PostIndexChanged.Response response; NamedPipeMessages.PostIndexChanged.Request request = new NamedPipeMessages.PostIndexChanged.Request(message); if (request == null) { response = new NamedPipeMessages.PostIndexChanged.Response(NamedPipeMessages.UnknownRequest); } else if (this.currentState != MountState.Ready) { response = new NamedPipeMessages.PostIndexChanged.Response(NamedPipeMessages.MountNotReadyResult); } else { if (this.resetForDehydrateInProgress) { // To avoid having to parse the index twice when dehydrating folders, repurpose the PostIndexChangedRequest // for git reset to rebuild the projection. Additionally, if we were to call ForceIndexProjectionUpdate // directly in HandleDehydrateFolders we'd have a race condition where the OnIndexWriteRequiringModifiedPathsValidation // background task would be trying to parse the index at the same time as HandleDehydrateFolders this.fileSystemCallbacks.ForceIndexProjectionUpdate(invalidateProjection: true, invalidateModifiedPaths: false); } else { this.fileSystemCallbacks.ForceIndexProjectionUpdate(request.UpdatedWorkingDirectory, request.UpdatedSkipWorktreeBits); } response = new NamedPipeMessages.PostIndexChanged.Response(NamedPipeMessages.PostIndexChanged.SuccessResult); } connection.TrySendResponse(response.CreateMessage()); }
private void HandlePostIndexChangedRequest(NamedPipeMessages.Message message, NamedPipeServer.Connection connection) { NamedPipeMessages.PostIndexChanged.Response response; NamedPipeMessages.PostIndexChanged.Request request = new NamedPipeMessages.PostIndexChanged.Request(message); if (request == null) { response = new NamedPipeMessages.PostIndexChanged.Response(NamedPipeMessages.UnknownRequest); } else if (this.currentState != MountState.Ready) { response = new NamedPipeMessages.PostIndexChanged.Response(NamedPipeMessages.MountNotReadyResult); } else { this.fileSystemCallbacks.ForceIndexProjectionUpdate(request.UpdatedWorkingDirectory, request.UpdatedSkipWorktreeBits); response = new NamedPipeMessages.PostIndexChanged.Response(NamedPipeMessages.PostIndexChanged.SuccessResult); } connection.TrySendResponse(response.CreateMessage()); }
private void ForceProjectionChange(ITracer tracer, GVFSEnlistment enlistment) { string errorMessage = null; if (!this.ShowStatusWhileRunning( () => { NamedPipeMessages.PostIndexChanged.Response response = null; try { using (NamedPipeClient pipeClient = new NamedPipeClient(enlistment.NamedPipeName)) { if (!pipeClient.Connect()) { this.ReportErrorAndExit("Unable to connect to GVFS. Try running 'gvfs mount'"); } NamedPipeMessages.PostIndexChanged.Request request = new NamedPipeMessages.PostIndexChanged.Request(updatedWorkingDirectory: true, updatedSkipWorktreeBits: false); pipeClient.SendRequest(request.CreateMessage()); response = new NamedPipeMessages.PostIndexChanged.Response(NamedPipeMessages.Message.FromString(pipeClient.ReadRawResponse()).Header); return(response.Result == NamedPipeMessages.PostIndexChanged.SuccessResult); } } catch (BrokenPipeException e) { this.ReportErrorAndExit("Unable to communicate with GVFS: " + e.ToString()); return(false); } }, "Forcing a projection change", suppressGvfsLogMessage: true)) { this.WriteMessage(tracer, "Failed to change projection: " + errorMessage); } }