Skip to content

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

@pwfulghum

Description

@pwfulghum

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);
   }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions