Skip to content

Commit

Permalink
Merge pull request #175 from bezzad/fix/download_current_path
Browse files Browse the repository at this point in the history
fixed download file on current path without creating directory
  • Loading branch information
bezzad authored Nov 28, 2024
2 parents 1fcd1f3 + c946ba9 commit 7216e5b
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
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
5 changes: 2 additions & 3 deletions src/Downloader/Downloader.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<PropertyGroup>
<TargetFrameworks>net8.0;netstandard2.1;</TargetFrameworks>
<LangVersion>latestMajor</LangVersion>
<Version>3.3.0</Version>
<Version>3.3.1</Version>
<AssemblyVersion>3.2.1</AssemblyVersion>
<FileVersion>3.2.1</FileVersion>
<Title>Downloader</Title>
Expand All @@ -12,8 +12,7 @@
<PackageProjectUrl>https://github.com/bezzad/Downloader</PackageProjectUrl>
<RepositoryUrl>https://github.com/bezzad/Downloader</RepositoryUrl>
<PackageTags>download-manager, downloader, download, idm, internet, streaming, download-file, stream-downloader, multipart-download</PackageTags>
<PackageReleaseNotes>* Fixed package serialization conflicts.
* Fixed some bugs.</PackageReleaseNotes>
<PackageReleaseNotes>* Fixed download file on current path without create directory. issue #174 </PackageReleaseNotes>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>Downloader.snk</AssemblyOriginatorKeyFile>
<Copyright>Copyright (C) 2019-2023 Behzad Khosravifar</Copyright>
Expand Down

0 comments on commit 7216e5b

Please sign in to comment.