Fixed: Sabnzbd/NzbGet not processing history items properly after last update.

pull/1880/head v2.0.0.4689
Taloth Saldono 8 years ago
parent 372442af2c
commit 5613ab05e0

@ -99,6 +99,9 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.Blackhole
var result = Subject.GetItems().Single(); var result = Subject.GetItems().Single();
VerifyCompleted(result); VerifyCompleted(result);
result.CanBeRemoved.Should().BeFalse();
result.CanMoveFiles.Should().BeFalse();
} }
[Test] [Test]

@ -77,6 +77,9 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.Blackhole
var result = Subject.GetItems().Single(); var result = Subject.GetItems().Single();
VerifyCompleted(result); VerifyCompleted(result);
result.CanBeRemoved.Should().BeTrue();
result.CanMoveFiles.Should().BeTrue();
} }
[Test] [Test]

@ -19,6 +19,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DelugeTests
protected DelugeTorrent _downloading; protected DelugeTorrent _downloading;
protected DelugeTorrent _failed; protected DelugeTorrent _failed;
protected DelugeTorrent _completed; protected DelugeTorrent _completed;
protected DelugeTorrent _seeding;
[SetUp] [SetUp]
public void Setup() public void Setup()
@ -75,7 +76,11 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DelugeTests
Size = 1000, Size = 1000,
BytesDownloaded = 1000, BytesDownloaded = 1000,
Progress = 100.0, Progress = 100.0,
DownloadPath = "somepath" DownloadPath = "somepath",
IsAutoManaged = true,
StopAtRatio = true,
StopRatio = 1.0,
Ratio = 1.5
}; };
Mocker.GetMock<ITorrentFileInfoReader>() Mocker.GetMock<ITorrentFileInfoReader>()
@ -189,6 +194,9 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DelugeTests
PrepareClientToReturnCompletedItem(); PrepareClientToReturnCompletedItem();
var item = Subject.GetItems().Single(); var item = Subject.GetItems().Single();
VerifyCompleted(item); VerifyCompleted(item);
item.CanBeRemoved.Should().BeTrue();
item.CanMoveFiles.Should().BeTrue();
} }
[Test] [Test]
@ -248,11 +256,11 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DelugeTests
item.Status.Should().Be(expectedItemStatus); item.Status.Should().Be(expectedItemStatus);
} }
[TestCase(DelugeTorrentStatus.Paused, DownloadItemStatus.Completed, false)] [TestCase(DelugeTorrentStatus.Paused, DownloadItemStatus.Completed)]
[TestCase(DelugeTorrentStatus.Checking, DownloadItemStatus.Downloading, false)] [TestCase(DelugeTorrentStatus.Checking, DownloadItemStatus.Downloading)]
[TestCase(DelugeTorrentStatus.Queued, DownloadItemStatus.Completed, false)] [TestCase(DelugeTorrentStatus.Queued, DownloadItemStatus.Completed)]
[TestCase(DelugeTorrentStatus.Seeding, DownloadItemStatus.Completed, false)] [TestCase(DelugeTorrentStatus.Seeding, DownloadItemStatus.Completed)]
public void GetItems_should_return_completed_item_as_downloadItemStatus(string apiStatus, DownloadItemStatus expectedItemStatus, bool expectedValue) public void GetItems_should_return_completed_item_as_downloadItemStatus(string apiStatus, DownloadItemStatus expectedItemStatus)
{ {
_completed.State = apiStatus; _completed.State = apiStatus;
@ -261,26 +269,25 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DelugeTests
var item = Subject.GetItems().Single(); var item = Subject.GetItems().Single();
item.Status.Should().Be(expectedItemStatus); item.Status.Should().Be(expectedItemStatus);
item.CanBeRemoved.Should().Be(expectedValue);
item.CanMoveFiles.Should().Be(expectedValue);
} }
[Test] [TestCase(0.5, false)]
public void GetItems_should_check_share_ratio_for_moveFiles_and_remove() [TestCase(1.01, true)]
public void GetItems_should_check_share_ratio_for_moveFiles_and_remove(double ratio, bool canBeRemoved)
{ {
_completed.State = DelugeTorrentStatus.Paused; _completed.State = DelugeTorrentStatus.Paused;
_completed.IsAutoManaged = true; _completed.IsAutoManaged = true;
_completed.StopAtRatio = true; _completed.StopAtRatio = true;
_completed.StopRatio = 1.0; _completed.StopRatio = 1.0;
_completed.Ratio = 1.01; _completed.Ratio = ratio;
PrepareClientToReturnCompletedItem(); PrepareClientToReturnCompletedItem();
var item = Subject.GetItems().Single(); var item = Subject.GetItems().Single();
item.Status.Should().Be(DownloadItemStatus.Completed); item.Status.Should().Be(DownloadItemStatus.Completed);
item.CanMoveFiles.Should().BeTrue(); item.CanMoveFiles.Should().Be(canBeRemoved);
item.CanBeRemoved.Should().BeTrue(); item.CanBeRemoved.Should().Be(canBeRemoved);
} }
[Test] [Test]

@ -190,6 +190,9 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.HadoukenTests
PrepareClientToReturnCompletedItem(); PrepareClientToReturnCompletedItem();
var item = Subject.GetItems().Single(); var item = Subject.GetItems().Single();
VerifyCompleted(item); VerifyCompleted(item);
item.CanBeRemoved.Should().BeTrue();
item.CanMoveFiles.Should().BeTrue();
} }
[Test] [Test]
@ -298,7 +301,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.HadoukenTests
.Returns("hash"); .Returns("hash");
var result = Subject.Download(remoteEpisode); var result = Subject.Download(remoteEpisode);
Assert.IsFalse(result.Any(c => char.IsLower(c))); Assert.IsFalse(result.Any(c => char.IsLower(c)));
} }

@ -103,7 +103,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.NzbVortexTests
public void queued_item_should_have_required_properties() public void queued_item_should_have_required_properties()
{ {
GivenQueue(_queued); GivenQueue(_queued);
var result = Subject.GetItems().Single(); var result = Subject.GetItems().Single();
VerifyQueued(result); VerifyQueued(result);
@ -139,6 +139,9 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.NzbVortexTests
var result = Subject.GetItems().Single(); var result = Subject.GetItems().Single();
VerifyCompleted(result); VerifyCompleted(result);
result.CanBeRemoved.Should().BeTrue();
result.CanMoveFiles.Should().BeTrue();
} }
[Test] [Test]

@ -163,7 +163,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.NzbgetTests
GivenQueue(_queued); GivenQueue(_queued);
GivenHistory(null); GivenHistory(null);
var result = Subject.GetItems().Single(); var result = Subject.GetItems().Single();
VerifyQueued(result); VerifyQueued(result);
@ -204,6 +204,9 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.NzbgetTests
var result = Subject.GetItems().Single(); var result = Subject.GetItems().Single();
VerifyCompleted(result); VerifyCompleted(result);
result.CanBeRemoved.Should().BeTrue();
result.CanMoveFiles.Should().BeTrue();
} }
[Test] [Test]

@ -239,6 +239,9 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.SabnzbdTests
var result = Subject.GetItems().Single(); var result = Subject.GetItems().Single();
VerifyCompleted(result); VerifyCompleted(result);
result.CanBeRemoved.Should().BeTrue();
result.CanMoveFiles.Should().BeTrue();
} }
[Test] [Test]

@ -41,6 +41,9 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.TransmissionTests
PrepareClientToReturnCompletedItem(); PrepareClientToReturnCompletedItem();
var item = Subject.GetItems().Single(); var item = Subject.GetItems().Single();
VerifyCompleted(item); VerifyCompleted(item);
item.CanBeRemoved.Should().BeTrue();
item.CanMoveFiles.Should().BeTrue();
} }
[Test] [Test]

@ -222,6 +222,9 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.UTorrentTests
PrepareClientToReturnCompletedItem(); PrepareClientToReturnCompletedItem();
var item = Subject.GetItems().Single(); var item = Subject.GetItems().Single();
VerifyCompleted(item); VerifyCompleted(item);
item.CanBeRemoved.Should().BeTrue();
item.CanMoveFiles.Should().BeTrue();
} }
[Test] [Test]

@ -43,6 +43,9 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.VuzeTests
PrepareClientToReturnCompletedItem(); PrepareClientToReturnCompletedItem();
var item = Subject.GetItems().Single(); var item = Subject.GetItems().Single();
VerifyCompleted(item); VerifyCompleted(item);
item.CanBeRemoved.Should().BeTrue();
item.CanMoveFiles.Should().BeTrue();
} }
[Test] [Test]

@ -83,8 +83,6 @@ namespace NzbDrone.Core.Download.Clients.Nzbget
queueItem.TotalSize = totalSize; queueItem.TotalSize = totalSize;
queueItem.Category = item.Category; queueItem.Category = item.Category;
queueItem.DownloadClient = Definition.Name; queueItem.DownloadClient = Definition.Name;
queueItem.CanMoveFiles = true;
queueItem.CanBeRemoved = true;
if (globalStatus.DownloadPaused || remainingSize == pausedSize && remainingSize != 0) if (globalStatus.DownloadPaused || remainingSize == pausedSize && remainingSize != 0)
{ {
@ -147,6 +145,8 @@ namespace NzbDrone.Core.Download.Clients.Nzbget
historyItem.Message = $"PAR Status: {item.ParStatus} - Unpack Status: {item.UnpackStatus} - Move Status: {item.MoveStatus} - Script Status: {item.ScriptStatus} - Delete Status: {item.DeleteStatus} - Mark Status: {item.MarkStatus}"; historyItem.Message = $"PAR Status: {item.ParStatus} - Unpack Status: {item.UnpackStatus} - Move Status: {item.MoveStatus} - Script Status: {item.ScriptStatus} - Delete Status: {item.DeleteStatus} - Mark Status: {item.MarkStatus}";
historyItem.Status = DownloadItemStatus.Completed; historyItem.Status = DownloadItemStatus.Completed;
historyItem.RemainingTime = TimeSpan.Zero; historyItem.RemainingTime = TimeSpan.Zero;
historyItem.CanMoveFiles = true;
historyItem.CanBeRemoved = true;
if (item.DeleteStatus == "MANUAL") if (item.DeleteStatus == "MANUAL")
{ {

@ -78,8 +78,6 @@ namespace NzbDrone.Core.Download.Clients.Sabnzbd
queueItem.TotalSize = (long)(sabQueueItem.Size * 1024 * 1024); queueItem.TotalSize = (long)(sabQueueItem.Size * 1024 * 1024);
queueItem.RemainingSize = (long)(sabQueueItem.Sizeleft * 1024 * 1024); queueItem.RemainingSize = (long)(sabQueueItem.Sizeleft * 1024 * 1024);
queueItem.RemainingTime = sabQueueItem.Timeleft; queueItem.RemainingTime = sabQueueItem.Timeleft;
queueItem.CanBeRemoved = true;
queueItem.CanMoveFiles = true;
if (sabQueue.Paused || sabQueueItem.Status == SabnzbdDownloadStatus.Paused) if (sabQueue.Paused || sabQueueItem.Status == SabnzbdDownloadStatus.Paused)
{ {
@ -162,6 +160,8 @@ namespace NzbDrone.Core.Download.Clients.Sabnzbd
else if (sabHistoryItem.Status == SabnzbdDownloadStatus.Completed) else if (sabHistoryItem.Status == SabnzbdDownloadStatus.Completed)
{ {
historyItem.Status = DownloadItemStatus.Completed; historyItem.Status = DownloadItemStatus.Completed;
historyItem.CanBeRemoved = true;
historyItem.CanMoveFiles = true;
} }
else // Verifying/Moving etc else // Verifying/Moving etc
{ {

Loading…
Cancel
Save