From 369d7b291ede7f40930e6b126c20cdbd67eb2afd Mon Sep 17 00:00:00 2001 From: bezzad Date: Thu, 28 Nov 2024 17:53:58 +0330 Subject: [PATCH 1/2] fixed download file on current path without creating directory --- .../IntegrationTests/DownloadServiceTest.cs | 17 +++++++++++++++++ src/Downloader/AbstractDownloadService.cs | 2 +- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/Downloader.Test/IntegrationTests/DownloadServiceTest.cs b/src/Downloader.Test/IntegrationTests/DownloadServiceTest.cs index c1448181..48a98eb3 100644 --- a/src/Downloader.Test/IntegrationTests/DownloadServiceTest.cs +++ b/src/Downloader.Test/IntegrationTests/DownloadServiceTest.cs @@ -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); + } } \ No newline at end of file diff --git a/src/Downloader/AbstractDownloadService.cs b/src/Downloader/AbstractDownloadService.cs index 177f784d..c44832aa 100644 --- a/src/Downloader/AbstractDownloadService.cs +++ b/src/Downloader/AbstractDownloadService.cs @@ -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 } From c946ba91d1a0ae6d0ea8819529cb29523a936393 Mon Sep 17 00:00:00 2001 From: bezzad Date: Thu, 28 Nov 2024 17:57:40 +0330 Subject: [PATCH 2/2] updated version and changelog --- src/Downloader/Downloader.csproj | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/Downloader/Downloader.csproj b/src/Downloader/Downloader.csproj index e22d4a85..147acca4 100644 --- a/src/Downloader/Downloader.csproj +++ b/src/Downloader/Downloader.csproj @@ -2,7 +2,7 @@ net8.0;netstandard2.1; latestMajor - 3.3.0 + 3.3.1 3.2.1 3.2.1 Downloader @@ -12,8 +12,7 @@ https://github.com/bezzad/Downloader https://github.com/bezzad/Downloader download-manager, downloader, download, idm, internet, streaming, download-file, stream-downloader, multipart-download - * Fixed package serialization conflicts. -* Fixed some bugs. + * Fixed download file on current path without create directory. issue #174 true Downloader.snk Copyright (C) 2019-2023 Behzad Khosravifar