Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Every DownLoadAsync call results in downloading the full file TWICE! #39

Open
pwfulghum opened this issue Dec 31, 2024 · 0 comments
Open

Comments

@pwfulghum
Copy link

Why does DownloadAsync (by filename) .... download the whole file TWICE?

If you look at the code there are two "DownloadFileByNameAsync" calls, both will do the full transfer (with 100K) file.

Was the intent just to get a "HEAD" to get the length?

   public async Task<IApiResults<DownloadFileResponse>> DownloadAsync
       (DownloadFileByNameRequest request, Stream content, IProgress<ICopyProgress> progress, CancellationToken cancel)
   {
       return await _policy.InvokeDownload.ExecuteAsync(async () =>
       {
           var fileRequest = new DownloadFileByNameRequest(request.BucketName, request.FileName);
           var fileResults = await DownloadFileByNameAsync(fileRequest, null, null, cancel);

           if (fileResults.IsSuccessStatusCode)
           {
               if (fileResults.Response.ContentLength < Options.DownloadCutoffSize)
               {
                   return await DownloadFileByNameAsync(request, content, progress, cancel).ConfigureAwait(false);
               }
               else
               {
                   return await DownloadLargeFileAsync(fileRequest, fileResults, content, progress, cancel).ConfigureAwait(false);
               }
           }

           return fileResults;
       }).ConfigureAwait(false);
   }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant