static void ProcessExitResult(ProcessExitResultWithOutput result, TransferSpec spec) { switch (result.ExitCode) { case 0: break; case -1: throw new RsyncSoftProgramException( $"Aborted/Killed (PID: {result.Id}, Status: {result.ExitCode}). {CreateTransferExceptionMessage(spec)}", result.StandardOutput + result.StandardError, result.StartInfo.Arguments); case 35584: throw new RsyncSoftProgramException( $"Stackdump (PID: {result.Id}, Status: {result.ExitCode}). {CreateTransferExceptionMessage(spec)}", result.StandardOutput + result.StandardError, result.StartInfo.Arguments); case -1073741819: throw new RsyncCygwinProgramException( $"Cygwin fork/rebase problem (PID: {result.Id}, Status: {result.ExitCode}). {CreateTransferExceptionMessage(spec)}", result.StandardOutput + result.StandardError, result.StartInfo.Arguments); default: throw new RsyncException( $"Did not exit gracefully (PID: {result.Id}, Status: {result.ExitCode}). {CreateTransferExceptionMessage(spec)}", result.StandardOutput + result.StandardError, result.StartInfo.Arguments); } }
static void ProcessExitResult(ProcessExitResultWithOutput exitResult) { if (exitResult.ExitCode != 0) { throw exitResult.GenerateException(); } }
public ProcessExitResultWithOutput RunAndProcess(ITransferProgress progress, string source, string destination, RsyncOptions options = null) { var processInfo = BuildProcessInfo(progress, source, destination, options); return(ProcessExitResultWithOutput.FromProcessExitResult(_processManager.LaunchAndProcess(processInfo), progress.Output)); }
protected void HandleRsyncResponse(ProcessExitResultWithOutput response) { if (response.ExitCode == 0) { return; } throw new RsyncException( $"Rsync [{response.Id}] exited with code {response.ExitCode}\nOutput: {response.StandardOutput}\nError: {response.StandardError}"); }
public async Task <ProcessExitResultWithOutput> RunAndProcessAsync(ITransferProgress progress, string source, string destination, RsyncOptions options = null) { var processInfo = BuildProcessInfo(progress, source, destination, options); return (ProcessExitResultWithOutput.FromProcessExitResult( await _processManager.LaunchAndProcessAsync(processInfo).ConfigureAwait(false), progress.Output)); }
private static ProcessException BuildProcessException(ProcessStartInfo startInfo, string tool, ProcessExitResultWithOutput ret) => new ProcessException( string.Format("{6} [{7}] error: {0} while running: {1} {2} from {3}\nOutput: {4}\nError: {5}", ret.ExitCode, startInfo.FileName, startInfo.Arguments, startInfo.WorkingDirectory, ret.StandardOutput, ret.StandardError, tool ?? Path.GetFileNameWithoutExtension(startInfo.FileName), ret.Id));
public ProcessExitResultWithOutput RunAndProcess(ZsyncParams p) { TryHandleOldFiles(p.File); var processInfo = BuildProcessInfo(p); var r = ProcessExitResultWithOutput.FromProcessExitResult(_processManager.LaunchAndProcess(processInfo), p.Progress.Output); if (r.ExitCode == 0) { TryRemoveOldFiles(p.File); } return(r); }
public async Task <ProcessExitResultWithOutput> RunAndProcessAsync(ZsyncParams p) { TryHandleOldFiles(p.File); var processInfo = BuildProcessInfo(p); var r = ProcessExitResultWithOutput.FromProcessExitResult( await _processManager.LaunchAndProcessAsync(processInfo).ConfigureAwait(false), p.Progress.Output); if (r.ExitCode == 0) { TryRemoveOldFiles(p.File); } return(r); }
static void ProcessExitResult(ProcessExitResultWithOutput result, TransferSpec spec) { if (spec.Progress.ZsyncIncompatible) { throw new ZsyncIncompatibleException( $"Zsync Incompatible (PID: {result.Id}, Status: {result.ExitCode}). {CreateTransferExceptionMessage(spec)}", result.StandardOutput + result.StandardError, result.StartInfo.Arguments); } switch (result.ExitCode) { case 0: break; case -1: { if (spec.Progress.ZsyncLoopCount >= 2) { throw new ZsyncLoopDetectedException( $"Loop detected, aborted transfer (PID: {result.Id}, Status: {result.ExitCode}). {CreateTransferExceptionMessage(spec)}", result.StandardOutput + result.StandardError, result.StartInfo.Arguments); } throw new ZsyncSoftProgramException( $"Aborted/Killed (PID: {result.Id}, Status: {result.ExitCode}). {CreateTransferExceptionMessage(spec)}", result.StandardOutput + result.StandardError, result.StartInfo.Arguments); } case 1: throw new ZsyncSoftException( $"Could not retrieve file due to protocol error (not a zsync file?) (PID: {result.Id}, Status: {result.ExitCode}). {CreateTransferExceptionMessage(spec)}", result.StandardOutput + result.StandardError, result.StartInfo.Arguments); case 2: throw new ZsyncSoftException( $"Connection reset (PID: {result.Id}, Status: {result.ExitCode}). {CreateTransferExceptionMessage(spec)}", result.StandardOutput + result.StandardError, result.StartInfo.Arguments); case 3: var statusCode = FindStatusCode("" + result.StandardOutput + result.StandardError); try { throw new ZsyncSoftException( $"Could not retrieve file (PID: {result.Id}, Status: {result.ExitCode}). {CreateTransferExceptionMessage(spec)}", result.StandardOutput + result.StandardError, result.StartInfo.Arguments); } catch (ZsyncSoftException ex) { switch (statusCode) { case -1: throw; case 404: throw new RequestFailedException("Received a 404: NotFound response", ex); case 403: throw new RequestFailedException("Received a 403: Forbidden response", ex); case 401: throw new RequestFailedException("Received a 401: Unauthorized response", ex); } throw; } case 21: throw new ZsyncSoftProgramException( $"Retrieved file but could not rename (PID: {result.Id}, Status: {result.ExitCode}). {CreateTransferExceptionMessage(spec)}", result.StandardOutput + result.StandardError, result.StartInfo.Arguments); case 35584: throw new ZsyncSoftProgramException( $"Stackdump (PID: {result.Id}, Status: {result.ExitCode}). {CreateTransferExceptionMessage(spec)}", result.StandardOutput + result.StandardError, result.StartInfo.Arguments); case -1073741819: throw new ZsyncCygwinProgramException( $"Cygwin fork/rebase problem (PID: {result.Id}, Status: {result.ExitCode}). {CreateTransferExceptionMessage(spec)}", result.StandardOutput + result.StandardError, result.StartInfo.Arguments); default: throw new ZsyncException( $"Did not exit gracefully (PID: {result.Id}, Status: {result.ExitCode}). {CreateTransferExceptionMessage(spec)}", result.StandardOutput + result.StandardError, result.StartInfo.Arguments); } }
static void ProcessExitResult(ProcessExitResultWithOutput result, TransferSpec spec) { switch (result.ExitCode) { case 0: break; case -1: throw new RsyncSoftProgramException( $"Aborted/Killed (PID: {result.Id}, Status: {result.ExitCode}). {CreateTransferExceptionMessage(spec)}", result.StandardOutput + result.StandardError, result.StartInfo.Arguments); case 5: throw new RsyncSoftException( $"Server full (PID: {result.Id}, Status: {result.ExitCode}). {CreateTransferExceptionMessage(spec)}", result.StandardOutput + result.StandardError, result.StartInfo.Arguments); case 10: throw new RsyncSoftException( $"Connection refused (PID: {result.Id}, Status: {result.ExitCode}). {CreateTransferExceptionMessage(spec)}", result.StandardOutput + result.StandardError, result.StartInfo.Arguments); case 12: throw new RsyncSoftException( $"Could not retrieve file (PID: {result.Id}, Status: {result.ExitCode}). {CreateTransferExceptionMessage(spec)}", result.StandardOutput + result.StandardError, result.StartInfo.Arguments); case 14: throw new RsyncSoftException( $"Could not retrieve file due to IPC error (PID: {result.Id}, Status: {result.ExitCode}). {CreateTransferExceptionMessage(spec)}", result.StandardOutput + result.StandardError, result.StartInfo.Arguments); case 23: throw new RsyncSoftException( $"Could not retrieve file (PID: {result.Id}, Status: {result.ExitCode}). {CreateTransferExceptionMessage(spec)}", result.StandardOutput + result.StandardError, result.StartInfo.Arguments); case 24: throw new RsyncSoftException( $"Could not retrieve file (PID: {result.Id}, Status: {result.ExitCode}). {CreateTransferExceptionMessage(spec)}", result.StandardOutput + result.StandardError, result.StartInfo.Arguments); case 30: throw new RsyncSoftException( $"Could not retrieve file due to Timeout (PID: {result.Id}, Status: {result.ExitCode}). {CreateTransferExceptionMessage(spec)}", result.StandardOutput + result.StandardError, result.StartInfo.Arguments); case 35: throw new RsyncSoftException( $"Could not retrieve file due to Timeout (PID: {result.Id}, Status: {result.ExitCode}). {CreateTransferExceptionMessage(spec)}", result.StandardOutput + result.StandardError, result.StartInfo.Arguments); case 35584: throw new RsyncSoftProgramException( $"Stackdump (PID: {result.Id}, Status: {result.ExitCode}). {CreateTransferExceptionMessage(spec)}", result.StandardOutput + result.StandardError, result.StartInfo.Arguments); case -1073741819: throw new RsyncCygwinProgramException( $"Cygwin fork/rebase problem (PID: {result.Id}, Status: {result.ExitCode}). {CreateTransferExceptionMessage(spec)}", result.StandardOutput + result.StandardError, result.StartInfo.Arguments); default: throw new RsyncException( $"Did not exit gracefully (PID: {result.Id}, Status: {result.ExitCode}). {CreateTransferExceptionMessage(spec)}", result.StandardOutput + result.StandardError, result.StartInfo.Arguments); } }