Skip to content

Commit 7216e5b

Browse files
authored
Merge pull request #175 from bezzad/fix/download_current_path
fixed download file on current path without creating directory
2 parents 1fcd1f3 + c946ba9 commit 7216e5b

File tree

3 files changed

+20
-4
lines changed

3 files changed

+20
-4
lines changed

src/Downloader.Test/IntegrationTests/DownloadServiceTest.cs

+17
Original file line numberDiff line numberDiff line change
@@ -768,4 +768,21 @@ public void TestAddLogger()
768768
// assert
769769
Assert.NotNull(Logger);
770770
}
771+
772+
[Fact]
773+
public async Task DownloadOnCurrentDirectory()
774+
{
775+
// arrange
776+
Options = GetDefaultConfig();
777+
var url = DummyFileHelper.GetFileWithNameUrl(Filename, DummyFileHelper.FileSize1Kb);
778+
var path = Filename;
779+
780+
// act
781+
await DownloadFileTaskAsync(url, path);
782+
783+
// assert
784+
Assert.True(Package.IsSaveComplete);
785+
Assert.Equal(Filename, Package.FileName);
786+
Assert.True(File.Exists(Package.FileName), "FileName: " + Package.FileName);
787+
}
771788
}

src/Downloader/AbstractDownloadService.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ protected async Task StartDownload(string fileName)
371371
{
372372
Package.FileName = fileName;
373373
string dirName = Path.GetDirectoryName(fileName);
374-
if (dirName != null)
374+
if (!string.IsNullOrWhiteSpace(dirName))
375375
{
376376
Directory.CreateDirectory(dirName); // ensure the folder is existing
377377
}

src/Downloader/Downloader.csproj

+2-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<PropertyGroup>
33
<TargetFrameworks>net8.0;netstandard2.1;</TargetFrameworks>
44
<LangVersion>latestMajor</LangVersion>
5-
<Version>3.3.0</Version>
5+
<Version>3.3.1</Version>
66
<AssemblyVersion>3.2.1</AssemblyVersion>
77
<FileVersion>3.2.1</FileVersion>
88
<Title>Downloader</Title>
@@ -12,8 +12,7 @@
1212
<PackageProjectUrl>https://github.com/bezzad/Downloader</PackageProjectUrl>
1313
<RepositoryUrl>https://github.com/bezzad/Downloader</RepositoryUrl>
1414
<PackageTags>download-manager, downloader, download, idm, internet, streaming, download-file, stream-downloader, multipart-download</PackageTags>
15-
<PackageReleaseNotes>* Fixed package serialization conflicts.
16-
* Fixed some bugs.</PackageReleaseNotes>
15+
<PackageReleaseNotes>* Fixed download file on current path without create directory. issue #174 </PackageReleaseNotes>
1716
<SignAssembly>true</SignAssembly>
1817
<AssemblyOriginatorKeyFile>Downloader.snk</AssemblyOriginatorKeyFile>
1918
<Copyright>Copyright (C) 2019-2023 Behzad Khosravifar</Copyright>

0 commit comments

Comments
 (0)