Downloader icon indicating copy to clipboard operation
Downloader copied to clipboard

Attempting to download the same file to the local directory with same name doesnt overwrite/replace

Open aravindk777 opened this issue 1 year ago • 2 comments

Description

When attempting to download the same file to the local directory with the same filename that exists already, the library is not overwriting/replacing or throwing any sort of error/message.

Usage

await DownloadBuilder.New()
    .WithConfiguration(_downloadSettings)
    .WithUrl(sourceUrl)
    .WithDirectory(localPath)
    .WithFileName(localFileName)
    .Build()
    .StartAsync();

How to reproduce

  • Create a file/download a file from any source for this issue.
  • Download to a determined localPath variable directory with the localFileName variable valued file name.
  • Reattempt to download another file with the same localFileName to the localPath
  • New file with size is not reflecting in the local path, but instead the old file is retained.

aravindk777 avatar Oct 31 '23 04:10 aravindk777

Reopening this, as the problem is, the library appends the new file being downloaded to the already existing file under the local path with the same name, instead of overwriting entirely or throwing an error.

For reproducing this,

  • Download a sample csv file to the local path. (say, it may have 1000 rows)
  • Download another different csv file to the local path, but with the same filename (say, it may have 5k rows)
  • Check the file contents after 2nd download attempt
  • File content seems to have merged or appended but not overwritten.

aravindk777 avatar Oct 31 '23 06:10 aravindk777

Hi @aravindk777, I have some unit tests and integration tests for this scenario and all of them passed. I think you have some config that can produce this issue. Please append your download config info to check more.

my test is:

image

bezzad avatar Nov 02 '23 09:11 bezzad