private async Task <string> TryDownloadAndGetHash(R2Package localPkg, CancellationToken cancelTkn) { SetStatus("Verifying uploaded parts ..."); var downloadedPkgPath = await _downloadr .DownloadAndUnpack(localPkg, _fileIO.TempDir, cancelTkn); var newHash = _fileIO.GetSHA1(downloadedPkgPath); await _fileIO.Delete(downloadedPkgPath); return(newHash); }
public async Task UpdateTarget(CancellationToken cancelTkn) { if (_remotePkg == null) { throw Fault .BadCall(nameof(TargetIsOutdated), nameof(UpdateTarget)); } var unpackd = string.Empty; try { unpackd = await _downloadr.DownloadAndUnpack (_remotePkg, _file.TempDir, cancelTkn); } catch (Exception ex) { SetStatus(ex.Info(false, true)); } if (unpackd.IsBlank()) { return; } CheckHash(unpackd, "downloaded-unpacked package"); if (!(await RetireCurrentPackage(true))) { if (!(await RetireCurrentPackage(false))) { StopCheckingForUpdates(); return; } } await PromoteNewerPackage(unpackd); CheckHash(TargetPath, "downloaded-unpacked-placed package"); StopCheckingForUpdates(); RaiseTargetUpdated(); }