MCPcopy Create free account
hub / github.com/Squirrel/Squirrel.Windows / Update

Method Update

src/Update/Program.cs:190–222  ·  view source on GitHub ↗
(string updateUrl, string appName = null)

Source from the content-addressed store, hash-verified

188 }
189
190 public async Task Update(string updateUrl, string appName = null)
191 {
192 appName = appName ?? getAppNameFromDirectory();
193
194 this.Log().Info("Starting update, downloading from " + updateUrl);
195
196 using (var mgr = new UpdateManager(updateUrl, appName)) {
197 bool ignoreDeltaUpdates = false;
198 this.Log().Info("About to update to: " + mgr.RootAppDirectory);
199
200 retry:
201 try {
202 var updateInfo = await mgr.CheckForUpdate(intention: UpdaterIntention.Update, ignoreDeltaUpdates: ignoreDeltaUpdates, progress: x => Console.WriteLine(x / 3));
203 await mgr.DownloadReleases(updateInfo.ReleasesToApply, x => Console.WriteLine(33 + x / 3));
204 await mgr.ApplyReleases(updateInfo, x => Console.WriteLine(66 + x / 3));
205 } catch (Exception ex) {
206 if (ignoreDeltaUpdates) {
207 this.Log().ErrorException("Really couldn't apply updates!", ex);
208 throw;
209 }
210
211 this.Log().WarnException("Failed to apply updates, falling back to full updates", ex);
212 ignoreDeltaUpdates = true;
213 goto retry;
214 }
215
216 var updateTarget = Path.Combine(mgr.RootAppDirectory, "Update.exe");
217
218 await this.ErrorIfThrows(() =>
219 mgr.CreateUninstallerRegistryEntry(),
220 "Failed to create uninstaller registry entry");
221 }
222 }
223
224 public async Task UpdateSelf()
225 {

Callers

nothing calls this directly

Calls 9

ErrorIfThrowsMethod · 0.80
InfoMethod · 0.45
LogMethod · 0.45
CheckForUpdateMethod · 0.45
DownloadReleasesMethod · 0.45
ApplyReleasesMethod · 0.45
ErrorExceptionMethod · 0.45
WarnExceptionMethod · 0.45

Tested by

no test coverage detected