mirror of
https://github.com/Readarr/Readarr
synced 2026-01-07 16:13:05 +01:00
Fixed DownloadFile when file already exists
This commit is contained in:
parent
3c335d498e
commit
5ef55d2180
2 changed files with 8 additions and 3 deletions
|
|
@ -300,12 +300,12 @@ public void should_not_download_file_with_error()
|
|||
{
|
||||
var file = GetTempFilePath();
|
||||
|
||||
Assert.Throws<HttpException>(() => Subject.DownloadFile("https://download.readarr.com/wrongpath", file));
|
||||
Assert.Throws<WebException>(() => Subject.DownloadFile("https://download.readarr.com/wrongpath", file));
|
||||
|
||||
File.Exists(file).Should().BeFalse();
|
||||
File.Exists(file + ".part").Should().BeFalse();
|
||||
|
||||
ExceptionVerification.ExpectedWarns(1);
|
||||
ExceptionVerification.ExpectedWarns(0);
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
|
|
|||
|
|
@ -258,6 +258,11 @@ public void DownloadFile(string url, string fileName, string userAgent = null)
|
|||
}
|
||||
|
||||
stopWatch.Stop();
|
||||
if (File.Exists(fileName))
|
||||
{
|
||||
File.Delete(fileName);
|
||||
}
|
||||
|
||||
File.Move(fileNamePart, fileName);
|
||||
_logger.Debug("Downloading Completed. took {0:0}s", stopWatch.Elapsed.Seconds);
|
||||
}
|
||||
|
|
@ -266,7 +271,7 @@ public void DownloadFile(string url, string fileName, string userAgent = null)
|
|||
if (File.Exists(fileNamePart))
|
||||
{
|
||||
File.Delete(fileNamePart);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue