Fixed: Import from torrent Download Station should move since DS maintains an internal copy for seeding.

Marcelo Castagna 7 years ago committed by Taloth
parent e48600da42
commit ea1616586f

@ -114,7 +114,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DelugeTests
.Returns("CBC2F069FE8BB2F544EAE707D75BCD3DE9DCF951".ToLower()) .Returns("CBC2F069FE8BB2F544EAE707D75BCD3DE9DCF951".ToLower())
.Callback(PrepareClientToReturnQueuedItem); .Callback(PrepareClientToReturnQueuedItem);
} }
protected virtual void GivenTorrents(List<DelugeTorrent> torrents) protected virtual void GivenTorrents(List<DelugeTorrent> torrents)
{ {
if (torrents == null) if (torrents == null)
@ -129,7 +129,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DelugeTests
protected void PrepareClientToReturnQueuedItem() protected void PrepareClientToReturnQueuedItem()
{ {
GivenTorrents(new List<DelugeTorrent> GivenTorrents(new List<DelugeTorrent>
{ {
_queued _queued
}); });
@ -137,7 +137,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DelugeTests
protected void PrepareClientToReturnDownloadingItem() protected void PrepareClientToReturnDownloadingItem()
{ {
GivenTorrents(new List<DelugeTorrent> GivenTorrents(new List<DelugeTorrent>
{ {
_downloading _downloading
}); });
@ -145,7 +145,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DelugeTests
protected void PrepareClientToReturnFailedItem() protected void PrepareClientToReturnFailedItem()
{ {
GivenTorrents(new List<DelugeTorrent> GivenTorrents(new List<DelugeTorrent>
{ {
_failed _failed
}); });
@ -248,11 +248,11 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DelugeTests
item.Status.Should().Be(expectedItemStatus); item.Status.Should().Be(expectedItemStatus);
} }
[TestCase(DelugeTorrentStatus.Paused, DownloadItemStatus.Completed, true)] [TestCase(DelugeTorrentStatus.Paused, DownloadItemStatus.Completed, false)]
[TestCase(DelugeTorrentStatus.Checking, DownloadItemStatus.Downloading, true)] [TestCase(DelugeTorrentStatus.Checking, DownloadItemStatus.Downloading, false)]
[TestCase(DelugeTorrentStatus.Queued, DownloadItemStatus.Completed, true)] [TestCase(DelugeTorrentStatus.Queued, DownloadItemStatus.Completed, false)]
[TestCase(DelugeTorrentStatus.Seeding, DownloadItemStatus.Completed, true)] [TestCase(DelugeTorrentStatus.Seeding, DownloadItemStatus.Completed, false)]
public void GetItems_should_return_completed_item_as_downloadItemStatus(string apiStatus, DownloadItemStatus expectedItemStatus, bool expectedReadOnly) public void GetItems_should_return_completed_item_as_downloadItemStatus(string apiStatus, DownloadItemStatus expectedItemStatus, bool expectedValue)
{ {
_completed.State = apiStatus; _completed.State = apiStatus;
@ -261,11 +261,12 @@ 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.IsReadOnly.Should().Be(expectedReadOnly); item.CanBeRemoved.Should().Be(expectedValue);
item.CanMoveFiles.Should().Be(expectedValue);
} }
[Test] [Test]
public void GetItems_should_check_share_ratio_for_readonly() public void GetItems_should_check_share_ratio_for_moveFiles_and_remove()
{ {
_completed.State = DelugeTorrentStatus.Paused; _completed.State = DelugeTorrentStatus.Paused;
_completed.IsAutoManaged = true; _completed.IsAutoManaged = true;
@ -278,7 +279,8 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DelugeTests
var item = Subject.GetItems().Single(); var item = Subject.GetItems().Single();
item.Status.Should().Be(DownloadItemStatus.Completed); item.Status.Should().Be(DownloadItemStatus.Completed);
item.IsReadOnly.Should().BeFalse(); item.CanMoveFiles.Should().BeTrue();
item.CanBeRemoved.Should().BeTrue();
} }
[Test] [Test]

@ -576,11 +576,11 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests
items.Should().OnlyContain(v => !v.OutputPath.IsEmpty); items.Should().OnlyContain(v => !v.OutputPath.IsEmpty);
} }
[TestCase(DownloadStationTaskStatus.Downloading, DownloadItemStatus.Downloading, true)] [TestCase(DownloadStationTaskStatus.Downloading, false, false)]
[TestCase(DownloadStationTaskStatus.Finished, DownloadItemStatus.Completed, false)] [TestCase(DownloadStationTaskStatus.Finished, true, true)]
[TestCase(DownloadStationTaskStatus.Seeding, DownloadItemStatus.Completed, true)] [TestCase(DownloadStationTaskStatus.Seeding, true, false)]
[TestCase(DownloadStationTaskStatus.Waiting, DownloadItemStatus.Queued, true)] [TestCase(DownloadStationTaskStatus.Waiting, false, false)]
public void GetItems_should_return_readonly_expected(DownloadStationTaskStatus apiStatus, DownloadItemStatus expectedItemStatus, bool readOnlyExpected) public void GetItems_should_return_canBeMoved_and_canBeDeleted_as_expected(DownloadStationTaskStatus apiStatus, bool canMoveFilesExpected, bool canBeRemovedExpected)
{ {
GivenSerialNumber(); GivenSerialNumber();
GivenSharedFolder(); GivenSharedFolder();
@ -592,7 +592,11 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests
var items = Subject.GetItems(); var items = Subject.GetItems();
items.Should().HaveCount(1); items.Should().HaveCount(1);
items.First().IsReadOnly.Should().Be(readOnlyExpected);
var item = items.First();
item.CanBeRemoved.Should().Be(canBeRemovedExpected);
item.CanMoveFiles.Should().Be(canMoveFilesExpected);
} }
[TestCase(DownloadStationTaskStatus.Downloading, DownloadItemStatus.Downloading)] [TestCase(DownloadStationTaskStatus.Downloading, DownloadItemStatus.Downloading)]

@ -408,24 +408,6 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests
items.Should().OnlyContain(v => !v.OutputPath.IsEmpty); items.Should().OnlyContain(v => !v.OutputPath.IsEmpty);
} }
[TestCase(DownloadStationTaskStatus.Downloading, DownloadItemStatus.Downloading, true)]
[TestCase(DownloadStationTaskStatus.Finished, DownloadItemStatus.Completed, false)]
[TestCase(DownloadStationTaskStatus.Waiting, DownloadItemStatus.Queued, true)]
public void GetItems_should_return_readonly_expected(DownloadStationTaskStatus apiStatus, DownloadItemStatus expectedItemStatus, bool readOnlyExpected)
{
GivenSerialNumber();
GivenSharedFolder();
_queued.Status = apiStatus;
GivenTasks(new List<DownloadStationTask>() { _queued });
var items = Subject.GetItems();
items.Should().HaveCount(1);
items.First().IsReadOnly.Should().Be(readOnlyExpected);
}
[TestCase(DownloadStationTaskStatus.Downloading, DownloadItemStatus.Downloading)] [TestCase(DownloadStationTaskStatus.Downloading, DownloadItemStatus.Downloading)]
[TestCase(DownloadStationTaskStatus.Error, DownloadItemStatus.Failed)] [TestCase(DownloadStationTaskStatus.Error, DownloadItemStatus.Failed)]
[TestCase(DownloadStationTaskStatus.Extracting, DownloadItemStatus.Downloading)] [TestCase(DownloadStationTaskStatus.Extracting, DownloadItemStatus.Downloading)]

@ -311,7 +311,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.QBittorrentTests
} }
[Test] [Test]
public void should_be_read_only_if_max_ratio_not_reached() public void should_not_be_removable_and_should_not_allow_move_files_if_max_ratio_not_reached()
{ {
GivenMaxRatio(1.0f); GivenMaxRatio(1.0f);
@ -330,11 +330,12 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.QBittorrentTests
GivenTorrents(new List<QBittorrentTorrent> { torrent }); GivenTorrents(new List<QBittorrentTorrent> { torrent });
var item = Subject.GetItems().Single(); var item = Subject.GetItems().Single();
item.IsReadOnly.Should().BeTrue(); item.CanBeRemoved.Should().BeFalse();
item.CanMoveFiles.Should().BeFalse();
} }
[Test] [Test]
public void should_be_read_only_if_max_ratio_reached_and_not_paused() public void should_not_be_removable_and_should_not_allow_move_files_if_max_ratio_reached_and_not_paused()
{ {
GivenMaxRatio(1.0f); GivenMaxRatio(1.0f);
@ -353,11 +354,12 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.QBittorrentTests
GivenTorrents(new List<QBittorrentTorrent> { torrent }); GivenTorrents(new List<QBittorrentTorrent> { torrent });
var item = Subject.GetItems().Single(); var item = Subject.GetItems().Single();
item.IsReadOnly.Should().BeTrue(); item.CanBeRemoved.Should().BeFalse();
item.CanMoveFiles.Should().BeFalse();
} }
[Test] [Test]
public void should_be_read_only_if_max_ratio_is_not_set() public void should_not_be_removable_and_should_not_allow_move_files_if_max_ratio_is_not_set()
{ {
GivenMaxRatio(1.0f, false); GivenMaxRatio(1.0f, false);
@ -376,11 +378,12 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.QBittorrentTests
GivenTorrents(new List<QBittorrentTorrent> { torrent }); GivenTorrents(new List<QBittorrentTorrent> { torrent });
var item = Subject.GetItems().Single(); var item = Subject.GetItems().Single();
item.IsReadOnly.Should().BeTrue(); item.CanBeRemoved.Should().BeFalse();
item.CanMoveFiles.Should().BeFalse();
} }
[Test] [Test]
public void should_not_be_read_only_if_max_ratio_reached_and_paused() public void should_be_removable_and_should_allow_move_files_if_max_ratio_reached_and_paused()
{ {
GivenMaxRatio(1.0f); GivenMaxRatio(1.0f);
@ -399,7 +402,8 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.QBittorrentTests
GivenTorrents(new List<QBittorrentTorrent> { torrent }); GivenTorrents(new List<QBittorrentTorrent> { torrent });
var item = Subject.GetItems().Single(); var item = Subject.GetItems().Single();
item.IsReadOnly.Should().BeFalse(); item.CanBeRemoved.Should().BeTrue();
item.CanMoveFiles.Should().BeTrue();
} }
[Test] [Test]

@ -172,13 +172,13 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.TransmissionTests
item.Status.Should().Be(expectedItemStatus); item.Status.Should().Be(expectedItemStatus);
} }
[TestCase(TransmissionTorrentStatus.Stopped, DownloadItemStatus.Completed, false)] [TestCase(TransmissionTorrentStatus.Stopped, DownloadItemStatus.Completed, true)]
[TestCase(TransmissionTorrentStatus.CheckWait, DownloadItemStatus.Downloading, true)] [TestCase(TransmissionTorrentStatus.CheckWait, DownloadItemStatus.Downloading, false)]
[TestCase(TransmissionTorrentStatus.Check, DownloadItemStatus.Downloading, true)] [TestCase(TransmissionTorrentStatus.Check, DownloadItemStatus.Downloading, false)]
[TestCase(TransmissionTorrentStatus.Queued, DownloadItemStatus.Completed, true)] [TestCase(TransmissionTorrentStatus.Queued, DownloadItemStatus.Completed, false)]
[TestCase(TransmissionTorrentStatus.SeedingWait, DownloadItemStatus.Completed, true)] [TestCase(TransmissionTorrentStatus.SeedingWait, DownloadItemStatus.Completed, false)]
[TestCase(TransmissionTorrentStatus.Seeding, DownloadItemStatus.Completed, true)] [TestCase(TransmissionTorrentStatus.Seeding, DownloadItemStatus.Completed, false)]
public void GetItems_should_return_completed_item_as_downloadItemStatus(TransmissionTorrentStatus apiStatus, DownloadItemStatus expectedItemStatus, bool expectedReadOnly) public void GetItems_should_return_completed_item_as_downloadItemStatus(TransmissionTorrentStatus apiStatus, DownloadItemStatus expectedItemStatus, bool expectedValue)
{ {
_completed.Status = apiStatus; _completed.Status = apiStatus;
@ -187,7 +187,8 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.TransmissionTests
var item = Subject.GetItems().Single(); var item = Subject.GetItems().Single();
item.Status.Should().Be(expectedItemStatus); item.Status.Should().Be(expectedItemStatus);
item.IsReadOnly.Should().Be(expectedReadOnly); item.CanBeRemoved.Should().Be(expectedValue);
item.CanMoveFiles.Should().Be(expectedValue);
} }
[Test] [Test]

@ -292,12 +292,12 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.UTorrentTests
item.Status.Should().Be(expectedItemStatus); item.Status.Should().Be(expectedItemStatus);
} }
[TestCase(UTorrentTorrentStatus.Loaded | UTorrentTorrentStatus.Checking, DownloadItemStatus.Queued, false)] [TestCase(UTorrentTorrentStatus.Loaded | UTorrentTorrentStatus.Checking, DownloadItemStatus.Queued, true)]
[TestCase(UTorrentTorrentStatus.Loaded | UTorrentTorrentStatus.Checked, DownloadItemStatus.Completed, false)] [TestCase(UTorrentTorrentStatus.Loaded | UTorrentTorrentStatus.Checked, DownloadItemStatus.Completed, true)]
[TestCase(UTorrentTorrentStatus.Loaded | UTorrentTorrentStatus.Checked | UTorrentTorrentStatus.Queued, DownloadItemStatus.Completed, true)] [TestCase(UTorrentTorrentStatus.Loaded | UTorrentTorrentStatus.Checked | UTorrentTorrentStatus.Queued, DownloadItemStatus.Completed, false)]
[TestCase(UTorrentTorrentStatus.Loaded | UTorrentTorrentStatus.Checked | UTorrentTorrentStatus.Started, DownloadItemStatus.Completed, true)] [TestCase(UTorrentTorrentStatus.Loaded | UTorrentTorrentStatus.Checked | UTorrentTorrentStatus.Started, DownloadItemStatus.Completed, false)]
[TestCase(UTorrentTorrentStatus.Loaded | UTorrentTorrentStatus.Checked | UTorrentTorrentStatus.Queued | UTorrentTorrentStatus.Paused, DownloadItemStatus.Completed, true)] [TestCase(UTorrentTorrentStatus.Loaded | UTorrentTorrentStatus.Checked | UTorrentTorrentStatus.Queued | UTorrentTorrentStatus.Paused, DownloadItemStatus.Completed, false)]
public void GetItems_should_return_completed_item_as_downloadItemStatus(UTorrentTorrentStatus apiStatus, DownloadItemStatus expectedItemStatus, bool expectedReadOnly) public void GetItems_should_return_completed_item_as_downloadItemStatus(UTorrentTorrentStatus apiStatus, DownloadItemStatus expectedItemStatus, bool expectedValue)
{ {
_completed.Status = apiStatus; _completed.Status = apiStatus;
@ -306,7 +306,8 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.UTorrentTests
var item = Subject.GetItems().Single(); var item = Subject.GetItems().Single();
item.Status.Should().Be(expectedItemStatus); item.Status.Should().Be(expectedItemStatus);
item.IsReadOnly.Should().Be(expectedReadOnly); item.CanBeRemoved.Should().Be(expectedValue);
item.CanMoveFiles.Should().Be(expectedValue);
} }
[Test] [Test]

@ -174,13 +174,13 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.VuzeTests
item.Status.Should().Be(expectedItemStatus); item.Status.Should().Be(expectedItemStatus);
} }
[TestCase(TransmissionTorrentStatus.Stopped, DownloadItemStatus.Completed, false)] [TestCase(TransmissionTorrentStatus.Stopped, DownloadItemStatus.Completed, true)]
[TestCase(TransmissionTorrentStatus.CheckWait, DownloadItemStatus.Downloading, true)] [TestCase(TransmissionTorrentStatus.CheckWait, DownloadItemStatus.Downloading, false)]
[TestCase(TransmissionTorrentStatus.Check, DownloadItemStatus.Downloading, true)] [TestCase(TransmissionTorrentStatus.Check, DownloadItemStatus.Downloading, false)]
[TestCase(TransmissionTorrentStatus.Queued, DownloadItemStatus.Completed, true)] [TestCase(TransmissionTorrentStatus.Queued, DownloadItemStatus.Completed, false)]
[TestCase(TransmissionTorrentStatus.SeedingWait, DownloadItemStatus.Completed, true)] [TestCase(TransmissionTorrentStatus.SeedingWait, DownloadItemStatus.Completed, false)]
[TestCase(TransmissionTorrentStatus.Seeding, DownloadItemStatus.Completed, true)] [TestCase(TransmissionTorrentStatus.Seeding, DownloadItemStatus.Completed, false)]
public void GetItems_should_return_completed_item_as_downloadItemStatus(TransmissionTorrentStatus apiStatus, DownloadItemStatus expectedItemStatus, bool expectedReadOnly) public void GetItems_should_return_completed_item_as_downloadItemStatus(TransmissionTorrentStatus apiStatus, DownloadItemStatus expectedItemStatus, bool expectedValue)
{ {
_completed.Status = apiStatus; _completed.Status = apiStatus;
@ -189,7 +189,8 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.VuzeTests
var item = Subject.GetItems().Single(); var item = Subject.GetItems().Single();
item.Status.Should().Be(expectedItemStatus); item.Status.Should().Be(expectedItemStatus);
item.IsReadOnly.Should().Be(expectedReadOnly); item.CanBeRemoved.Should().Be(expectedValue);
item.CanMoveFiles.Should().Be(expectedValue);
} }
[Test] [Test]
@ -312,4 +313,4 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.VuzeTests
} }
} }
} }

@ -81,10 +81,10 @@ namespace NzbDrone.Core.Test.HistoryTests
Path = @"C:\Test\Unsorted\Series.s01e01.mkv" Path = @"C:\Test\Unsorted\Series.s01e01.mkv"
}; };
Subject.Handle(new EpisodeImportedEvent(localEpisode, episodeFile, true, "sab", "abcd", true)); Subject.Handle(new EpisodeImportedEvent(localEpisode, episodeFile, true, "sab", "abcd"));
Mocker.GetMock<IHistoryRepository>() Mocker.GetMock<IHistoryRepository>()
.Verify(v => v.Insert(It.Is<History.History>(h => h.SourceTitle == Path.GetFileNameWithoutExtension(localEpisode.Path)))); .Verify(v => v.Insert(It.Is<History.History>(h => h.SourceTitle == Path.GetFileNameWithoutExtension(localEpisode.Path))));
} }
} }
} }

@ -224,9 +224,9 @@ namespace NzbDrone.Core.Test.MediaFiles
} }
[Test] [Test]
public void should_copy_readonly_downloads() public void should_copy_when_cannot_move_files_downloads()
{ {
Subject.Import(new List<ImportDecision> { _approvedDecisions.First() }, true, new DownloadClientItem { Title = "30.Rock.S01E01", IsReadOnly = true }); Subject.Import(new List<ImportDecision> { _approvedDecisions.First() }, true, new DownloadClientItem { Title = "30.Rock.S01E01", CanMoveFiles = false});
Mocker.GetMock<IUpgradeMediaFiles>() Mocker.GetMock<IUpgradeMediaFiles>()
.Verify(v => v.UpgradeEpisodeFile(It.IsAny<EpisodeFile>(), _approvedDecisions.First().LocalEpisode, true), Times.Once()); .Verify(v => v.UpgradeEpisodeFile(It.IsAny<EpisodeFile>(), _approvedDecisions.First().LocalEpisode, true), Times.Once());
@ -235,7 +235,7 @@ namespace NzbDrone.Core.Test.MediaFiles
[Test] [Test]
public void should_use_override_importmode() public void should_use_override_importmode()
{ {
Subject.Import(new List<ImportDecision> { _approvedDecisions.First() }, true, new DownloadClientItem { Title = "30.Rock.S01E01", IsReadOnly = true }, ImportMode.Move); Subject.Import(new List<ImportDecision> { _approvedDecisions.First() }, true, new DownloadClientItem { Title = "30.Rock.S01E01", CanMoveFiles = false }, ImportMode.Move);
Mocker.GetMock<IUpgradeMediaFiles>() Mocker.GetMock<IUpgradeMediaFiles>()
.Verify(v => v.UpgradeEpisodeFile(It.IsAny<EpisodeFile>(), _approvedDecisions.First().LocalEpisode, false), Times.Once()); .Verify(v => v.UpgradeEpisodeFile(It.IsAny<EpisodeFile>(), _approvedDecisions.First().LocalEpisode, false), Times.Once());

@ -103,7 +103,8 @@ namespace NzbDrone.Core.Download.Clients.Blackhole
Status = item.Status, Status = item.Status,
IsReadOnly = Settings.ReadOnly CanMoveFiles = !Settings.ReadOnly,
CanBeRemoved = !Settings.ReadOnly
}; };
} }
} }

@ -68,7 +68,10 @@ namespace NzbDrone.Core.Download.Clients.Blackhole
OutputPath = item.OutputPath, OutputPath = item.OutputPath,
Status = item.Status Status = item.Status,
CanBeRemoved = true,
CanMoveFiles = true
}; };
} }
} }

@ -138,14 +138,7 @@ namespace NzbDrone.Core.Download.Clients.Deluge
} }
// Here we detect if Deluge is managing the torrent and whether the seed criteria has been met. This allows drone to delete the torrent as appropriate. // Here we detect if Deluge is managing the torrent and whether the seed criteria has been met. This allows drone to delete the torrent as appropriate.
if (torrent.IsAutoManaged && torrent.StopAtRatio && torrent.Ratio >= torrent.StopRatio && torrent.State == DelugeTorrentStatus.Paused) item.CanMoveFiles = item.CanBeRemoved = (torrent.IsAutoManaged && torrent.StopAtRatio && torrent.Ratio >= torrent.StopRatio && torrent.State == DelugeTorrentStatus.Paused);
{
item.IsReadOnly = false;
}
else
{
item.IsReadOnly = true;
}
items.Add(item); items.Add(item);
} }
@ -178,7 +171,7 @@ namespace NzbDrone.Core.Download.Clients.Deluge
{ {
status.OutputRootFolders = new List<OsPath> { _remotePathMappingService.RemapRemoteToLocal(Settings.Host, destDir) }; status.OutputRootFolders = new List<OsPath> { _remotePathMappingService.RemapRemoteToLocal(Settings.Host, destDir) };
} }
return status; return status;
} }

@ -90,7 +90,8 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation
RemainingTime = GetRemainingTime(torrent), RemainingTime = GetRemainingTime(torrent),
Status = GetStatus(torrent), Status = GetStatus(torrent),
Message = GetMessage(torrent), Message = GetMessage(torrent),
IsReadOnly = !IsFinished(torrent) CanMoveFiles = IsCompleted(torrent),
CanBeRemoved = IsFinished(torrent)
}; };
if (item.Status == DownloadItemStatus.Completed || item.Status == DownloadItemStatus.Failed) if (item.Status == DownloadItemStatus.Completed || item.Status == DownloadItemStatus.Failed)
@ -199,6 +200,11 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation
return torrent.Status == DownloadStationTaskStatus.Finished; return torrent.Status == DownloadStationTaskStatus.Finished;
} }
protected bool IsCompleted(DownloadStationTask torrent)
{
return torrent.Status == DownloadStationTaskStatus.Seeding || IsFinished(torrent) || (torrent.Status == DownloadStationTaskStatus.Waiting && torrent.Size != 0 && GetRemainingSize(torrent) <= 0);
}
protected string GetMessage(DownloadStationTask torrent) protected string GetMessage(DownloadStationTask torrent)
{ {
if (torrent.StatusExtra != null) if (torrent.StatusExtra != null)

@ -99,7 +99,8 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation
RemainingSize = taskRemainingSize, RemainingSize = taskRemainingSize,
Status = GetStatus(nzb), Status = GetStatus(nzb),
Message = GetMessage(nzb), Message = GetMessage(nzb),
IsReadOnly = !IsFinished(nzb) CanBeRemoved = true,
CanMoveFiles = true
}; };
if (item.Status != DownloadItemStatus.Paused) if (item.Status != DownloadItemStatus.Paused)
@ -291,11 +292,6 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation
return null; return null;
} }
protected bool IsFinished(DownloadStationTask task)
{
return task.Status == DownloadStationTaskStatus.Finished;
}
protected string GetMessage(DownloadStationTask task) protected string GetMessage(DownloadStationTask task)
{ {
if (task.StatusExtra != null) if (task.StatusExtra != null)

@ -97,14 +97,7 @@ namespace NzbDrone.Core.Download.Clients.Hadouken
item.Status = DownloadItemStatus.Downloading; item.Status = DownloadItemStatus.Downloading;
} }
if (torrent.IsFinished && torrent.State == HadoukenTorrentState.Paused) item.CanMoveFiles = item.CanBeRemoved = (torrent.IsFinished && torrent.State == HadoukenTorrentState.Paused);
{
item.IsReadOnly = false;
}
else
{
item.IsReadOnly = true;
}
items.Add(item); items.Add(item);
} }
@ -170,7 +163,7 @@ namespace NzbDrone.Core.Download.Clients.Hadouken
if (version < new Version("5.1")) if (version < new Version("5.1"))
{ {
return new ValidationFailure(string.Empty, "Old Hadouken client with unsupported API, need 5.1 or higher"); return new ValidationFailure(string.Empty, "Old Hadouken client with unsupported API, need 5.1 or higher");
} }
} }
catch (DownloadClientAuthenticationException ex) catch (DownloadClientAuthenticationException ex)

@ -72,7 +72,9 @@ namespace NzbDrone.Core.Download.Clients.NzbVortex
queueItem.TotalSize = vortexQueueItem.TotalDownloadSize; queueItem.TotalSize = vortexQueueItem.TotalDownloadSize;
queueItem.RemainingSize = vortexQueueItem.TotalDownloadSize - vortexQueueItem.DownloadedSize; queueItem.RemainingSize = vortexQueueItem.TotalDownloadSize - vortexQueueItem.DownloadedSize;
queueItem.RemainingTime = null; queueItem.RemainingTime = null;
queueItem.CanBeRemoved = true;
queueItem.CanMoveFiles = true;
if (vortexQueueItem.IsPaused) if (vortexQueueItem.IsPaused)
{ {
queueItem.Status = DownloadItemStatus.Paused; queueItem.Status = DownloadItemStatus.Paused;
@ -132,7 +134,7 @@ namespace NzbDrone.Core.Download.Clients.NzbVortex
{ {
_proxy.Remove(queueItem.Id, deleteData, Settings); _proxy.Remove(queueItem.Id, deleteData, Settings);
} }
} }
} }
protected List<NzbVortexGroup> GetGroups() protected List<NzbVortexGroup> GetGroups()
@ -256,4 +258,4 @@ namespace NzbDrone.Core.Download.Clients.NzbVortex
return new OsPath(Path.Combine(outputPath.FullPath, filesResponse.First().FileName)); return new OsPath(Path.Combine(outputPath.FullPath, filesResponse.First().FileName));
} }
} }
} }

@ -83,6 +83,8 @@ 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)
{ {

@ -77,6 +77,9 @@ namespace NzbDrone.Core.Download.Clients.Pneumatic
DownloadId = GetDownloadClientId(file), DownloadId = GetDownloadClientId(file),
Title = title, Title = title,
CanBeRemoved = true,
CanMoveFiles = true,
TotalSize = _diskProvider.GetFileSize(file), TotalSize = _diskProvider.GetFileSize(file),
OutputPath = new OsPath(file) OutputPath = new OsPath(file)

@ -106,7 +106,7 @@ namespace NzbDrone.Core.Download.Clients.QBittorrent
// Avoid removing torrents that haven't reached the global max ratio. // Avoid removing torrents that haven't reached the global max ratio.
// Removal also requires the torrent to be paused, in case a higher max ratio was set on the torrent itself (which is not exposed by the api). // Removal also requires the torrent to be paused, in case a higher max ratio was set on the torrent itself (which is not exposed by the api).
item.IsReadOnly = (config.MaxRatioEnabled && config.MaxRatio > torrent.Ratio) || torrent.State != "pausedUP"; item.CanMoveFiles = item.CanBeRemoved = (!config.MaxRatioEnabled || config.MaxRatio <= torrent.Ratio) && torrent.State == "pausedUP";
if (!item.OutputPath.IsEmpty && item.OutputPath.FileName != torrent.Name) if (!item.OutputPath.IsEmpty && item.OutputPath.FileName != torrent.Name)
{ {
@ -129,7 +129,7 @@ namespace NzbDrone.Core.Download.Clients.QBittorrent
item.Status = DownloadItemStatus.Queued; item.Status = DownloadItemStatus.Queued;
break; break;
case "pausedUP": // torrent is paused and has finished downloading case "pausedUP": // torrent is paused and has finished downloading:
case "uploading": // torrent is being seeded and data is being transfered case "uploading": // torrent is being seeded and data is being transfered
case "stalledUP": // torrent is being seeded, but no connection were made case "stalledUP": // torrent is being seeded, but no connection were made
case "queuedUP": // queuing is enabled and torrent is queued for upload case "queuedUP": // queuing is enabled and torrent is queued for upload

@ -78,6 +78,8 @@ 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)
{ {

@ -105,7 +105,7 @@ namespace NzbDrone.Core.Download.Clients.Transmission
item.Status = DownloadItemStatus.Downloading; item.Status = DownloadItemStatus.Downloading;
} }
item.IsReadOnly = torrent.Status != TransmissionTorrentStatus.Stopped; item.CanMoveFiles = item.CanBeRemoved = torrent.Status == TransmissionTorrentStatus.Stopped;
items.Add(item); items.Add(item);
} }
@ -122,7 +122,7 @@ namespace NzbDrone.Core.Download.Clients.Transmission
{ {
var config = _proxy.GetConfig(Settings); var config = _proxy.GetConfig(Settings);
var destDir = config.GetValueOrDefault("download-dir") as string; var destDir = config.GetValueOrDefault("download-dir") as string;
if (Settings.TvCategory.IsNotNullOrWhiteSpace()) if (Settings.TvCategory.IsNotNullOrWhiteSpace())
{ {
destDir = string.Format("{0}/.{1}", destDir, Settings.TvCategory); destDir = string.Format("{0}/.{1}", destDir, Settings.TvCategory);
@ -246,4 +246,4 @@ namespace NzbDrone.Core.Download.Clients.Transmission
return null; return null;
} }
} }
} }

@ -107,19 +107,31 @@ namespace NzbDrone.Core.Download.Clients.RTorrent
item.RemainingSize = torrent.RemainingSize; item.RemainingSize = torrent.RemainingSize;
item.Category = torrent.Category; item.Category = torrent.Category;
if (torrent.DownRate > 0) { if (torrent.DownRate > 0)
{
var secondsLeft = torrent.RemainingSize / torrent.DownRate; var secondsLeft = torrent.RemainingSize / torrent.DownRate;
item.RemainingTime = TimeSpan.FromSeconds(secondsLeft); item.RemainingTime = TimeSpan.FromSeconds(secondsLeft);
} else { }
else
{
item.RemainingTime = TimeSpan.Zero; item.RemainingTime = TimeSpan.Zero;
} }
if (torrent.IsFinished) item.Status = DownloadItemStatus.Completed; if (torrent.IsFinished)
else if (torrent.IsActive) item.Status = DownloadItemStatus.Downloading; {
else if (!torrent.IsActive) item.Status = DownloadItemStatus.Paused; item.Status = DownloadItemStatus.Completed;
}
else if (torrent.IsActive)
{
item.Status = DownloadItemStatus.Downloading;
}
else if (!torrent.IsActive)
{
item.Status = DownloadItemStatus.Paused;
}
// No stop ratio data is present, so do not delete // No stop ratio data is present, so do not delete
item.IsReadOnly = true; item.CanMoveFiles = item.CanBeRemoved = false;
items.Add(item); items.Add(item);
} }

@ -165,7 +165,7 @@ namespace NzbDrone.Core.Download.Clients.UTorrent
} }
// 'Started' without 'Queued' is when the torrent is 'forced seeding' // 'Started' without 'Queued' is when the torrent is 'forced seeding'
item.IsReadOnly = torrent.Status.HasFlag(UTorrentTorrentStatus.Queued) || torrent.Status.HasFlag(UTorrentTorrentStatus.Started); item.CanMoveFiles = item.CanBeRemoved = (!torrent.Status.HasFlag(UTorrentTorrentStatus.Queued) && !torrent.Status.HasFlag(UTorrentTorrentStatus.Started));
queueItems.Add(item); queueItems.Add(item);
} }

@ -21,7 +21,9 @@ namespace NzbDrone.Core.Download
public DownloadItemStatus Status { get; set; } public DownloadItemStatus Status { get; set; }
public bool IsEncrypted { get; set; } public bool IsEncrypted { get; set; }
public bool IsReadOnly { get; set; }
public bool CanMoveFiles { get; set; }
public bool CanBeRemoved { get; set; }
public bool Removed { get; set; } public bool Removed { get; set; }
} }

@ -37,7 +37,7 @@ namespace NzbDrone.Core.Download
{ {
if (!_configService.RemoveCompletedDownloads || if (!_configService.RemoveCompletedDownloads ||
message.TrackedDownload.DownloadItem.Removed || message.TrackedDownload.DownloadItem.Removed ||
message.TrackedDownload.DownloadItem.IsReadOnly || !message.TrackedDownload.DownloadItem.CanBeRemoved ||
message.TrackedDownload.DownloadItem.Status == DownloadItemStatus.Downloading) message.TrackedDownload.DownloadItem.Status == DownloadItemStatus.Downloading)
{ {
return; return;
@ -50,7 +50,7 @@ namespace NzbDrone.Core.Download
{ {
var trackedDownload = message.TrackedDownload; var trackedDownload = message.TrackedDownload;
if (trackedDownload == null || trackedDownload.DownloadItem.IsReadOnly || _configService.RemoveFailedDownloads == false) if (trackedDownload == null || !trackedDownload.DownloadItem.CanBeRemoved || _configService.RemoveFailedDownloads == false)
{ {
return; return;
} }
@ -78,4 +78,4 @@ namespace NzbDrone.Core.Download
} }
} }
} }
} }

@ -64,7 +64,7 @@ namespace NzbDrone.Core.Download.TrackedDownloads
{ {
var clientTrackedDownloads = ProcessClientDownloads(downloadClient); var clientTrackedDownloads = ProcessClientDownloads(downloadClient);
// Only track completed downloads if // Only track completed downloads if
trackedDownloads.AddRange(clientTrackedDownloads.Where(DownloadIsTrackable)); trackedDownloads.AddRange(clientTrackedDownloads.Where(DownloadIsTrackable));
} }
@ -107,7 +107,7 @@ namespace NzbDrone.Core.Download.TrackedDownloads
private void RemoveCompletedDownloads(List<TrackedDownload> trackedDownloads) private void RemoveCompletedDownloads(List<TrackedDownload> trackedDownloads)
{ {
foreach (var trackedDownload in trackedDownloads.Where(c => !c.DownloadItem.IsReadOnly && c.State == TrackedDownloadStage.Imported)) foreach (var trackedDownload in trackedDownloads.Where(c => c.DownloadItem.CanBeRemoved && c.State == TrackedDownloadStage.Imported))
{ {
_eventAggregator.PublishEvent(new DownloadCompletedEvent(trackedDownload)); _eventAggregator.PublishEvent(new DownloadCompletedEvent(trackedDownload));
} }

@ -185,7 +185,7 @@ namespace NzbDrone.Core.MediaFiles
var decisions = _importDecisionMaker.GetImportDecisions(videoFiles.ToList(), series, folderInfo, true); var decisions = _importDecisionMaker.GetImportDecisions(videoFiles.ToList(), series, folderInfo, true);
var importResults = _importApprovedEpisodes.Import(decisions, true, downloadClientItem, importMode); var importResults = _importApprovedEpisodes.Import(decisions, true, downloadClientItem, importMode);
if ((downloadClientItem == null || !downloadClientItem.IsReadOnly) && if ((downloadClientItem == null || downloadClientItem.CanMoveFiles) &&
importResults.Any(i => i.Result == ImportResultType.Imported) && importResults.Any(i => i.Result == ImportResultType.Imported) &&
ShouldDeleteFolder(directoryInfo, series)) ShouldDeleteFolder(directoryInfo, series))
{ {

@ -90,7 +90,7 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport
{ {
default: default:
case ImportMode.Auto: case ImportMode.Auto:
copyOnly = downloadClientItem != null && downloadClientItem.IsReadOnly; copyOnly = downloadClientItem != null && !downloadClientItem.CanMoveFiles;
break; break;
case ImportMode.Move: case ImportMode.Move:
copyOnly = false; copyOnly = false;
@ -122,7 +122,7 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport
if (downloadClientItem != null) if (downloadClientItem != null)
{ {
_eventAggregator.PublishEvent(new EpisodeImportedEvent(localEpisode, episodeFile, newDownload, downloadClientItem.DownloadClient, downloadClientItem.DownloadId, downloadClientItem.IsReadOnly)); _eventAggregator.PublishEvent(new EpisodeImportedEvent(localEpisode, episodeFile, newDownload, downloadClientItem.DownloadClient, downloadClientItem.DownloadId));//, !downloadClientItem.CanMoveFiles));
} }
else else
{ {

@ -251,7 +251,7 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport.Manual
{ {
if (_downloadedEpisodesImportService.ShouldDeleteFolder( if (_downloadedEpisodesImportService.ShouldDeleteFolder(
new DirectoryInfo(trackedDownload.DownloadItem.OutputPath.FullPath), new DirectoryInfo(trackedDownload.DownloadItem.OutputPath.FullPath),
trackedDownload.RemoteEpisode.Series) && !trackedDownload.DownloadItem.IsReadOnly) trackedDownload.RemoteEpisode.Series) && trackedDownload.DownloadItem.CanMoveFiles)
{ {
_diskProvider.DeleteFolder(trackedDownload.DownloadItem.OutputPath.FullPath, true); _diskProvider.DeleteFolder(trackedDownload.DownloadItem.OutputPath.FullPath, true);
} }

@ -10,7 +10,7 @@ namespace NzbDrone.Core.MediaFiles.Events
public bool NewDownload { get; private set; } public bool NewDownload { get; private set; }
public string DownloadClient { get; private set; } public string DownloadClient { get; private set; }
public string DownloadId { get; private set; } public string DownloadId { get; private set; }
public bool IsReadOnly { get; set; } //public bool IsReadOnly { get; set; }
public EpisodeImportedEvent(LocalEpisode episodeInfo, EpisodeFile importedEpisode, bool newDownload) public EpisodeImportedEvent(LocalEpisode episodeInfo, EpisodeFile importedEpisode, bool newDownload)
{ {
@ -19,14 +19,14 @@ namespace NzbDrone.Core.MediaFiles.Events
NewDownload = newDownload; NewDownload = newDownload;
} }
public EpisodeImportedEvent(LocalEpisode episodeInfo, EpisodeFile importedEpisode, bool newDownload, string downloadClient, string downloadId, bool isReadOnly) public EpisodeImportedEvent(LocalEpisode episodeInfo, EpisodeFile importedEpisode, bool newDownload, string downloadClient, string downloadId)//, bool isReadOnly)
{ {
EpisodeInfo = episodeInfo; EpisodeInfo = episodeInfo;
ImportedEpisode = importedEpisode; ImportedEpisode = importedEpisode;
NewDownload = newDownload; NewDownload = newDownload;
DownloadClient = downloadClient; DownloadClient = downloadClient;
DownloadId = downloadId; DownloadId = downloadId;
IsReadOnly = isReadOnly; // IsReadOnly = isReadOnly;
} }
} }
} }

Loading…
Cancel
Save