protected virtual async Task DownloadAsyncInternal(FileDownloadSpec spec) { ConfirmStrategySupported(spec.Uri); spec.LocalFile.RemoveReadonlyWhenExists(); try { await GetStrategy(spec.Uri).DownloadAsync(spec).ConfigureAwait(false); } finally { ResetSpec(spec); } }
protected virtual void DownloadInternal(FileDownloadSpec spec) { ConfirmStrategySupported(spec.Uri); spec.LocalFile.RemoveReadonlyWhenExists(); try { GetStrategy(spec.Uri).Download(spec); } catch { ResetSpec(spec); } }
FileDownloadSpec GetSpec(FileDownloadSpec spec) => spec.Progress == null ? new FileDownloadSpec(_authProvider.HandleUri(spec.Uri), spec.LocalFile) { Verification = spec.Verification, CancellationToken = spec.CancellationToken, ExistingFile = spec.ExistingFile } : new FileDownloadSpec(_authProvider.HandleUri(spec.Uri), spec.LocalFile, spec.Progress) { Verification = spec.Verification, CancellationToken = spec.CancellationToken, ExistingFile = spec.ExistingFile };
public Task DownloadAsync(FileDownloadSpec spec) => Wrap(() => _downloader.DownloadAsync(spec), spec);
public void Download(FileDownloadSpec spec) { Wrap(() => _downloader.Download(spec), spec); }
private void ResetSpec(FileDownloadSpec spec) => spec.Progress?.Update(null, 100);
public Task DownloadAsync(FileDownloadSpec spec) => DownloadAsyncInternal(GetSpec(spec));
public void Download(FileDownloadSpec spec) => DownloadInternal(GetSpec(spec));