/// <summary>
        /// Update passed GitClient object.
        /// Throw GitOperationException on unrecoverable errors.
        /// Throw CancelledByUserException and RepeatOperationException.
        /// </summary>
        async internal Task UpdateAsync(GitClient client, IInstantProjectChecker instantChecker,
                                        Action <string> onProgressChange)
        {
            if (client.DoesRequireClone() && !isCloneAllowed(client.Path))
            {
                InitializationStatusChange?.Invoke("Clone rejected");
                throw new CancelledByUserException();
            }

            InitializationStatusChange?.Invoke("Updating git repository...");

            await runAsync(async() => await client.Updater.ManualUpdateAsync(instantChecker, onProgressChange));

            InitializationStatusChange?.Invoke("Git repository updated");
        }
示例#2
0
        async public Task ManualUpdateAsync(IInstantProjectChecker instantChecker, Action <string> onProgressChange)
        {
            Trace.TraceInformation(
                String.Format("[GitClientUpdater] Processing manual update. Stored LatestChange: {0}. ProjectChecker: {1}",
                              _latestChange.ToLocalTime().ToString(), (instantChecker?.ToString() ?? "null")));

            if (instantChecker == null)
            {
                Trace.TraceError(String.Format("[GitClientUpdater] Unexpected case, manual update w/o instant checker"));
                Debug.Assert(false);
                return;
            }

            _updating = true;
            try
            {
                DateTime newLatestChange = instantChecker.GetLatestChangeTimestamp();
                Trace.TraceInformation(String.Format("[GitClientUpdater] Repository Latest Change: {0}",
                                                     newLatestChange.ToLocalTime().ToString()));

                // this may cancel currently running onTimer update
                await checkTimestampAndUpdate(newLatestChange, onProgressChange);
            }
            finally
            {
                _updating = false;
            }

            // if doUpdate succeeded, it is ok to start periodic updates
            if (!_subscribed)
            {
                Trace.TraceInformation(String.Format("[GitClientUpdater] Subscribe to Project Watcher"));
                _projectWatcher.OnProjectUpdate += onProjectWatcherUpdate;
                _subscribed = true;
            }
        }