Exemplo n.º 1
0
        async Task DeployToTargetAsync(DataRecorder record, ICancelable task, SshTarget target,
                                       string localPath, string remotePath, bool force = false)
        {
            Stopwatch stopwatch = Stopwatch.StartNew();

            try
            {
                BinarySignatureCheck.Types.Result signatureCheck = force
                    ? BinarySignatureCheck.Types.Result.AlwaysCopy
                    : BinarySignatureCheck.Types.Result.YesCopy;

                record.SetCopyAttempted(true);
                record.BinarySize(FileUtil.GetFileSize(localPath, _fileSystem));
                record.SignatureCheckResult(signatureCheck);
                record.DeploymentMode();

                await _remoteFile.SyncAsync(target, localPath, remotePath, task, force);

                record.CopyBinary(stopwatch.ElapsedMilliseconds, DataRecorder.NoError);
            }
            catch (ProcessException exception)
            {
                record.CopyBinary(stopwatch.ElapsedMilliseconds, exception);
                throw new DeployException(
                          ErrorStrings.FailedToDeployExecutable(exception.Message),
                          exception);
            }
        }