public void SetUp()
 {
     _logger        = Substitute.For <PatchKit.Logging.ILogger>();
     _issueReporter = Substitute.For <PatchKit.IssueReporting.IIssueReporter>();
     _updaterStatus = new UpdaterStatus();
     _cache         = new MockCache();
 }
Example #2
0
        public override void Prepare(UpdaterStatus status)
        {
            base.Prepare(status);

            foreach (var entry in _entries)
            {
                var repairStatus = new OperationStatus
                {
                    Weight = { Value = StatusWeightHelper.GetUnarchivePackageWeight(entry.Size.Value) }
                };
                status.RegisterOperation(repairStatus);

                var downloadStatus = new DownloadStatus
                {
                    Weight = { Value = StatusWeightHelper.GetDownloadWeight(entry.Size.Value) }
                };
                status.RegisterOperation(downloadStatus);

                _entryStatus[entry] = new EntryStatus
                {
                    RepairStatus   = repairStatus,
                    DownloadStatus = downloadStatus
                };
            }

            _localData.PrepareForWriting();
        }
Example #3
0
        public AppUpdaterRepairAndDiffStrategy(AppUpdaterContext context, UpdaterStatus status)
        {
            Assert.IsNotNull(context, "Context is null");

            _repairStrategy = new AppUpdaterRepairStrategy(context, status);
            _diffStrategy   = new AppUpdaterDiffStrategy(context, status);
        }
Example #4
0
        public override void Prepare([NotNull] UpdaterStatus status, CancellationToken cancellationToken)
        {
            if (status == null)
            {
                throw new ArgumentNullException("status");
            }

            try
            {
                _logger.LogDebug("Preparing diff installation...");

                base.Prepare(status, cancellationToken);

                _localData.PrepareForWriting();

                _previousContentSummary = _remoteMetaData.GetContentSummary(_versionId - 1, cancellationToken);
                _contentSummary         = _remoteMetaData.GetContentSummary(_versionId, cancellationToken);
                _diffSummary            = _remoteMetaData.GetDiffSummary(_versionId, cancellationToken);

                double unarchivePackageWeight = StatusWeightHelper.GetUnarchivePackageWeight(_diffSummary.Size);
                _logger.LogTrace("unarchivePackageWeight = " + unarchivePackageWeight);
                _unarchivePackageStatusReporter = new OperationStatus
                {
                    Weight = { Value = unarchivePackageWeight }
                };
                status.RegisterOperation(_unarchivePackageStatusReporter);

                double addFilesWeight = StatusWeightHelper.GetAddDiffFilesWeight(_diffSummary);
                _logger.LogTrace("addFilesWeight = " + addFilesWeight);
                _addFilesStatusReporter = new OperationStatus
                {
                    Weight = { Value = addFilesWeight }
                };
                status.RegisterOperation(_addFilesStatusReporter);

                double modifiedFilesWeight = StatusWeightHelper.GetModifyDiffFilesWeight(_diffSummary);
                _logger.LogTrace("modifiedFilesWeight = " + modifiedFilesWeight);
                _modifiedFilesStatusReporter = new OperationStatus
                {
                    Weight = { Value = modifiedFilesWeight }
                };
                status.RegisterOperation(_modifiedFilesStatusReporter);

                double removeFilesWeight = StatusWeightHelper.GetRemoveDiffFilesWeight(_diffSummary);
                _logger.LogTrace("removeFilesWeight = " + removeFilesWeight);
                _removeFilesStatusReporter = new OperationStatus
                {
                    Weight = { Value = removeFilesWeight }
                };
                status.RegisterOperation(_removeFilesStatusReporter);

                _logger.LogDebug("Diff installation prepared.");
            }
            catch (Exception e)
            {
                _logger.LogError("Failed to prepare diff installation.", e);
                throw;
            }
        }
        public AppUpdaterDiffStrategy(AppUpdaterContext context, UpdaterStatus status)
        {
            DebugLogger.LogConstructor();
            Checks.ArgumentNotNull(context, "context");

            _context = context;
            _status  = status;
        }
        public AppUpdaterRepairStrategy(AppUpdaterContext context, UpdaterStatus status)
        {
            Assert.IsNotNull(context, "Context is null");

            _context = context;
            _status  = status;

            _logger = PatcherLogManager.DefaultLogger;
        }
        public override void Prepare([NotNull] UpdaterStatus status, CancellationToken cancellationToken)
        {
            base.Prepare(status, cancellationToken);

            if (status == null)
            {
                throw new ArgumentNullException("status");
            }
        }
Example #8
0
        public override void Prepare([NotNull] UpdaterStatus status)
        {
            base.Prepare(status);

            if (status == null)
            {
                throw new ArgumentNullException("status");
            }
        }
 public void Prepare(UpdaterStatus status, CancellationToken cancellationToken)
 {
     // do nothing
     _status = new OperationStatus
     {
         Weight      = { Value = 0.00001 },
         Description = { Value = "Allocating disk space..." }
     };
     status.RegisterOperation(_status);
 }
Example #10
0
 internal void AsyncAbort(UpdaterStatus status)
 {
     try
     {
         this.BeginInvoke(new UpdateHandler(this.Abort), status);
     }
     catch (InvalidOperationException)
     {
         // Guess the dialog wasn't ready -- just ignore
     }
 }
Example #11
0
 private void updateStatus(UpdaterStatus newStatus)
 {
     CurrentStatus = newStatus;
     if (StatusUpdated != null)
     {
         App.Current.Dispatcher.Invoke(new Action(delegate
         {
             StatusUpdated(this);
         }), null);
     }
 }
        public AppRepairer(AppUpdaterContext context, UpdaterStatus status)
        {
            DebugLogger.LogConstructor();

            Checks.ArgumentNotNull(context, "context");

            Context = context;
            _status = status;

            _strategyResolver = new AppUpdaterStrategyResolver(_status);
            _commandFactory   = new AppUpdaterCommandFactory();
        }
Example #13
0
        public AppUpdaterContentStrategy(AppUpdaterContext context, UpdaterStatus status)
        {
            Checks.ArgumentNotNull(context, "context");

            DebugLogger.LogConstructor();

            _context = context;
            _status  = status;

            // defaults
            RepairOnError = true;
        }
Example #14
0
        // download latest updates
        private bool DownloadNewVersion(bool checkAutoDownloadFlag = false)
        {
            bool res = false;

            try
            {
                // There's already a new version ready to set up
                if (this.IsDownloadComplete)
                {
                    return(res);
                }

                // If an operation is being done, do not interfere
                UpdaterStatus state = (UpdaterStatus)this.state.Current;
                if ((state == UpdaterStatus.ManifestDownloadCompleted ||
                     state == UpdaterStatus.Idle))
                {
                    res = true;
                    UpdateManifestInfo info = GetNewVersionInfo();
                    if (info != null)
                    {
                        this.NewVersionDetails = info.ChangeLog;

                        if ((checkAutoDownloadFlag && Settings.Instance.AutoDownloadUpdate) ||
                            !checkAutoDownloadFlag)
                        {
                            EventLogger.Instance.Add("Found new version.");

                            this.state.Current = UpdaterStatus.DownloadingPackage;
                            res = this.downloader.BeginDownloadPackage(info);
                        }
                        else
                        {
                            EventLogger.Instance.Add("Found new version auto download is off. It'll not be downloaded.");
                        }
                    }

                    if ((UpdaterStatus)this.state.Current != UpdaterStatus.DownloadingPackage)
                    {
                        this.state.Current = UpdaterStatus.Idle;
                    }
                }
            }
            catch (Exception ex)
            {
                this.state.Current = UpdaterStatus.Idle;
                EventLogger.Instance.Add(ex.Message);
                res = false;
            }

            return(res);
        }
        public override void Prepare(UpdaterStatus status)
        {
            base.Prepare(status);

            Checks.ArgumentNotNull(status, "statusMonitor");

            DebugLogger.Log("Preparing version integrity check.");

            _status = new OperationStatus
            {
                Weight      = { Value = StatusWeightHelper.GetCheckVersionIntegrityWeight(_versionSummary) },
                Description = { Value = "Checking version integrity..." }
            };
            status.RegisterOperation(_status);
        }
Example #16
0
        public override void Prepare(UpdaterStatus status, CancellationToken cancellationToken)
        {
            base.Prepare(status, cancellationToken);

            Checks.ArgumentNotNull(status, "statusMonitor");

            DebugLogger.Log("Preparing uninstallation.");

            _localData.PrepareForWriting();

            _statusReporter = new OperationStatus
            {
                Weight = { Value = StatusWeightHelper.GetUninstallWeight() }
            };
            status.RegisterOperation(_statusReporter);
        }
        public override void Prepare(UpdaterStatus status)
        {
            base.Prepare(status);

            if (status == null)
            {
                throw new ArgumentNullException("status");
            }

            DebugLogger.Log("Preparing package download.");

            _status = new DownloadStatus
            {
                Weight      = { Value = StatusWeightHelper.GetResourceDownloadWeight(_resource) },
                Description = { Value = "Downloading package..." }
            };
            status.RegisterOperation(_status);
        }
        public override void Prepare(UpdaterStatus status)
        {
            base.Prepare(status);

            Checks.ArgumentNotNull(status, "statusMonitor");

            DebugLogger.Log("Preparing content installation.");

            _localData.PrepareForWriting();

            _copyFilesStatus = new OperationStatus
            {
                Weight = { Value = StatusWeightHelper.GetCopyContentFilesWeight(_versionContentSummary) }
            };
            status.RegisterOperation(_copyFilesStatus);

            _unarchivePackageStatus = new OperationStatus
            {
                Weight = { Value = StatusWeightHelper.GetUnarchivePackageWeight(_versionContentSummary.Size) }
            };
            status.RegisterOperation(_unarchivePackageStatus);
        }
Example #19
0
 // Called from the worker thread
 public void HandleUpdateStarted(object sender, UpdaterStatus status)
 {
     parentForm.AsyncInvokeScript(new ScriptCall(UpdateStartedMethod, new object[] { status.bytes, status.files }));
 }
Example #20
0
 // Called from the worker thread
 public void HandleUpdateCompleted(object sender, UpdaterStatus status)
 {
     parentForm.AsyncInvokeScript(new ScriptCall(UpdateCompletedMethod, new object[] { status.bytes, status.files, status.bytesFetched, status.bytesTransferred }));
 }
Example #21
0
 public AppUpdaterStrategyResolver(UpdaterStatus status)
 {
     _logger = PatcherLogManager.DefaultLogger;
     _status = status;
 }
Example #22
0
 // Called from the worker thread
 public void HandleUpdateAborted(object sender, UpdaterStatus status)
 {
     parentForm.AsyncInvokeScript(new ScriptCall(UpdateAbortedMethod, new object[] { status.message }),
                                  new MethodCall(new UpdateHandler(parentForm.Abort), new object[] { status.message }));
 }
 void OnDownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e)
 {
     Status = UpdaterStatus.Downloading;
     Progress = e.ProgressPercentage;
 }
 void FindAndInstallExtension()
 {
     var vsExtensionspath = Path.GetFullPath(Path.Combine(Environment.ExpandEnvironmentVariables("%VS140COMNTOOLS%"), @"..\IDE\Extensions\"));
     var userExtensionspath = Path.GetFullPath(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), @"Microsoft\VisualStudio\14.0\Extensions\"));
     string path;
     if(!FindExtensionFolder(userExtensionspath, out path) && !FindExtensionFolder(vsExtensionspath, out path)) {
         Status = UpdaterStatus.Error;
         return;
     }
     if (!Directory.Exists(path)) {
         Status = UpdaterStatus.Error;
         return;
     }
     var config = ConfigSerializer.GetConfig();
     config.InstallPath = path;
     ConfigSerializer.SaveConfig(config);
     if (LauncherHelper.UpdateLauncher(version: version))
         Status = UpdaterStatus.Restarting;
     else
         Status = UpdaterStatus.Error;
 }
 void StartDownload()
 {
     try {
         client.DownloadDataAsync(uri);
     } catch {
         Status = UpdaterStatus.Error;
     }
 }
Example #26
0
 public UpdaterProgressArgs(UpdaterStatus status, double progress)
 {
     Status   = status;
     Progress = progress;
 }
Example #27
0
 public void Prepare(UpdaterStatus status)
 {
     // not needed
 }
Example #28
0
 public virtual void Prepare(UpdaterStatus status, CancellationToken cancellationToken)
 {
     Assert.MethodCalledOnlyOnce(ref _prepareHasBeenCalled, "Prepare");
 }
Example #29
0
 public void Prepare(UpdaterStatus status, CancellationToken cancellationToken)
 {
     // not needed
 }
 void InstallCompleted()
 {
     vsixInstallerProcess.Exited -= VsixInstalCompleted;
     var hasError = vsixInstallerProcess.ExitCode != 0;
     vsixInstallerProcess.Dispose();
     if (hasError) {
         Status = UpdaterStatus.Error;
         return;
     }
     FindAndInstallExtension();
 }
Example #31
0
 private static void HandleUpdateCompleted(object sender, UpdaterStatus msg)
 {
     Console.WriteLine("Update Succeeded");
 }
Example #32
0
 // Called from the worker thread
 public void HandleUpdateProgress(object sender, UpdaterStatus status)
 {
     parentForm.AsyncInvokeScript(new ScriptCall(UpdateProgressMethod, new object[] { status.bytesFetched }));
     // System.Diagnostics.Trace.Write(string.Format("HandleUpdateProgress: {0}/{1}", status.bytesFetched, status.bytes));
 }
Example #33
0
 private static void HandleUpdateStarted(object sender, UpdaterStatus msg)
 {
     Console.WriteLine("Updating Media ...");
 }
 void DownloadDataCompleted(object sender, DownloadDataCompletedEventArgs e)
 {
     if (e.Error!=null)
         Status = UpdaterStatus.Error;
     else {
         var targetPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "installer_DXVcs2Git.GitTools.vsix");
         if (File.Exists(targetPath))
             File.Delete(targetPath);
         File.WriteAllBytes(targetPath, e.Result);
         Status = UpdaterStatus.Installing;
     }
 }
Example #35
0
 private static void HandleUpdateCompleted(object sender, UpdaterStatus msg)
 {
     Console.WriteLine("Update Succeeded");
 }
 public void Prepare(UpdaterStatus status)
 {
     // do nothing
 }
Example #37
0
 private static void HandleUpdateStarted(object sender, UpdaterStatus msg)
 {
     Console.WriteLine("Updating Media ...");
 }