Skip to content

Commit

Permalink
fixed download file on current path without creating directory
Browse files Browse the repository at this point in the history
  • Loading branch information
bezzad committed Nov 28, 2024
1 parent 1fcd1f3 commit 369d7b2
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
17 changes: 17 additions & 0 deletions src/Downloader.Test/IntegrationTests/DownloadServiceTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -768,4 +768,21 @@ public void TestAddLogger()
// assert
Assert.NotNull(Logger);
}

[Fact]
public async Task DownloadOnCurrentDirectory()
{
// arrange
Options = GetDefaultConfig();
var url = DummyFileHelper.GetFileWithNameUrl(Filename, DummyFileHelper.FileSize1Kb);
var path = Filename;

// act
await DownloadFileTaskAsync(url, path);

// assert
Assert.True(Package.IsSaveComplete);
Assert.Equal(Filename, Package.FileName);
Assert.True(File.Exists(Package.FileName), "FileName: " + Package.FileName);
}
}
2 changes: 1 addition & 1 deletion src/Downloader/AbstractDownloadService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ protected async Task StartDownload(string fileName)
{
Package.FileName = fileName;
string dirName = Path.GetDirectoryName(fileName);
if (dirName != null)
if (!string.IsNullOrWhiteSpace(dirName))
{
Directory.CreateDirectory(dirName); // ensure the folder is existing
}
Expand Down

0 comments on commit 369d7b2

Please sign in to comment.