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

fixed download file on current path without creating directory #175

Merged
merged 2 commits into from
Nov 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading