mirror of
https://github.com/lidarr/lidarr.git
synced 2025-08-21 05:53:33 -07:00
Proposal: Length is definitive, fallback to modified if no length
This commit is contained in:
parent
2be52c22d6
commit
8e777025cb
2 changed files with 29 additions and 11 deletions
|
@ -27,7 +27,7 @@ namespace NzbDrone.Core.Test.MediaCoverTests
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void should_return_false_if_file_exists_but_diffrent_date()
|
public void should_return_false_if_file_exists_but_different_date()
|
||||||
{
|
{
|
||||||
GivenFileExistsOnDisk(DateTime.Now);
|
GivenFileExistsOnDisk(DateTime.Now);
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@ namespace NzbDrone.Core.Test.MediaCoverTests
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void should_return_ture_if_file_exists_and_same_date_but_no_length_header()
|
public void should_return_true_if_file_exists_and_same_date_but_no_length_header()
|
||||||
{
|
{
|
||||||
var givenDate = DateTime.Now;
|
var givenDate = DateTime.Now;
|
||||||
|
|
||||||
|
@ -45,12 +45,31 @@ namespace NzbDrone.Core.Test.MediaCoverTests
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void should_return_ture_if_file_exists_and_date_header_is_null_but_has_length_header()
|
public void should_return_false_if_file_exists_and_same_date_but_length_header_different()
|
||||||
{
|
{
|
||||||
|
var givenDate = DateTime.Now;
|
||||||
|
|
||||||
|
GivenFileExistsOnDisk(givenDate);
|
||||||
|
|
||||||
|
Subject.AlreadyExists(givenDate, 999, "c:\\file.exe").Should().BeFalse();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void should_return_true_if_file_exists_and_date_header_is_null_but_has_length_header()
|
||||||
|
{
|
||||||
GivenFileExistsOnDisk(DateTime.Now);
|
GivenFileExistsOnDisk(DateTime.Now);
|
||||||
|
|
||||||
Subject.AlreadyExists(null, 1000, "c:\\file.exe").Should().BeTrue();
|
Subject.AlreadyExists(null, 1000, "c:\\file.exe").Should().BeTrue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void should_return_true_if_file_exists_and_date_header_is_different_but_length_header_the_same()
|
||||||
|
{
|
||||||
|
GivenFileExistsOnDisk(DateTime.Now.AddDays(-1));
|
||||||
|
|
||||||
|
Subject.AlreadyExists(DateTime.Now, 1000, "c:\\file.exe").Should().BeTrue();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
using System;
|
using System;
|
||||||
using NzbDrone.Common.Disk;
|
using NzbDrone.Common.Disk;
|
||||||
using NzbDrone.Common.Http;
|
|
||||||
|
|
||||||
namespace NzbDrone.Core.MediaCover
|
namespace NzbDrone.Core.MediaCover
|
||||||
{
|
{
|
||||||
|
@ -25,13 +24,6 @@ namespace NzbDrone.Core.MediaCover
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (serverModifiedDate.HasValue)
|
|
||||||
{
|
|
||||||
DateTime? lastModifiedLocal = _diskProvider.FileGetLastWrite(localPath);
|
|
||||||
|
|
||||||
return lastModifiedLocal.Value.ToUniversalTime() == serverModifiedDate.Value.ToUniversalTime();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (serverContentLength.HasValue && serverContentLength.Value > 0)
|
if (serverContentLength.HasValue && serverContentLength.Value > 0)
|
||||||
{
|
{
|
||||||
var fileSize = _diskProvider.GetFileSize(localPath);
|
var fileSize = _diskProvider.GetFileSize(localPath);
|
||||||
|
@ -39,6 +31,13 @@ namespace NzbDrone.Core.MediaCover
|
||||||
return fileSize == serverContentLength;
|
return fileSize == serverContentLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (serverModifiedDate.HasValue)
|
||||||
|
{
|
||||||
|
DateTime? lastModifiedLocal = _diskProvider.FileGetLastWrite(localPath);
|
||||||
|
|
||||||
|
return lastModifiedLocal.Value.ToUniversalTime() == serverModifiedDate.Value.ToUniversalTime();
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue