(string updateUrl, string appName = null)
| 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 | { |
nothing calls this directly
no test coverage detected