1
0
mirror of https://github.com/Radarr/Radarr.git synced 2024-11-04 10:02:40 +01:00

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

This commit is contained in:
Marcelo Castagna 2017-03-30 17:26:11 -03:00 committed by Taloth
parent e48600da42
commit ea1616586f
30 changed files with 139 additions and 129 deletions

View File

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

View File

@ -576,11 +576,11 @@ public void GetItems_should_map_outputpath_for_completed_or_failed_tasks()
items.Should().OnlyContain(v => !v.OutputPath.IsEmpty);
}
[TestCase(DownloadStationTaskStatus.Downloading, DownloadItemStatus.Downloading, true)]
[TestCase(DownloadStationTaskStatus.Finished, DownloadItemStatus.Completed, false)]
[TestCase(DownloadStationTaskStatus.Seeding, DownloadItemStatus.Completed, true)]
[TestCase(DownloadStationTaskStatus.Waiting, DownloadItemStatus.Queued, true)]
public void GetItems_should_return_readonly_expected(DownloadStationTaskStatus apiStatus, DownloadItemStatus expectedItemStatus, bool readOnlyExpected)
[TestCase(DownloadStationTaskStatus.Downloading, false, false)]
[TestCase(DownloadStationTaskStatus.Finished, true, true)]
[TestCase(DownloadStationTaskStatus.Seeding, true, false)]
[TestCase(DownloadStationTaskStatus.Waiting, false, false)]
public void GetItems_should_return_canBeMoved_and_canBeDeleted_as_expected(DownloadStationTaskStatus apiStatus, bool canMoveFilesExpected, bool canBeRemovedExpected)
{
GivenSerialNumber();
GivenSharedFolder();
@ -592,7 +592,11 @@ public void GetItems_should_return_readonly_expected(DownloadStationTaskStatus a
var items = Subject.GetItems();
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)]

View File

@ -408,24 +408,6 @@ public void GetItems_should_map_outputpath_for_completed_or_failed_tasks()
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.Error, DownloadItemStatus.Failed)]
[TestCase(DownloadStationTaskStatus.Extracting, DownloadItemStatus.Downloading)]

View File

@ -311,7 +311,7 @@ public void Download_should_handle_http_redirect_to_torrent()
}
[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);
@ -330,11 +330,12 @@ public void should_be_read_only_if_max_ratio_not_reached()
GivenTorrents(new List<QBittorrentTorrent> { torrent });
var item = Subject.GetItems().Single();
item.IsReadOnly.Should().BeTrue();
item.CanBeRemoved.Should().BeFalse();
item.CanMoveFiles.Should().BeFalse();
}
[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);
@ -353,11 +354,12 @@ public void should_be_read_only_if_max_ratio_reached_and_not_paused()
GivenTorrents(new List<QBittorrentTorrent> { torrent });
var item = Subject.GetItems().Single();
item.IsReadOnly.Should().BeTrue();
item.CanBeRemoved.Should().BeFalse();
item.CanMoveFiles.Should().BeFalse();
}
[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);
@ -376,11 +378,12 @@ public void should_be_read_only_if_max_ratio_is_not_set()
GivenTorrents(new List<QBittorrentTorrent> { torrent });
var item = Subject.GetItems().Single();
item.IsReadOnly.Should().BeTrue();
item.CanBeRemoved.Should().BeFalse();
item.CanMoveFiles.Should().BeFalse();
}
[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);
@ -399,7 +402,8 @@ public void should_not_be_read_only_if_max_ratio_reached_and_paused()
GivenTorrents(new List<QBittorrentTorrent> { torrent });
var item = Subject.GetItems().Single();
item.IsReadOnly.Should().BeFalse();
item.CanBeRemoved.Should().BeTrue();
item.CanMoveFiles.Should().BeTrue();
}
[Test]

View File

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

View File

@ -292,12 +292,12 @@ public void GetItems_should_return_downloading_item_as_downloadItemStatus(UTorre
item.Status.Should().Be(expectedItemStatus);
}
[TestCase(UTorrentTorrentStatus.Loaded | UTorrentTorrentStatus.Checking, DownloadItemStatus.Queued, false)]
[TestCase(UTorrentTorrentStatus.Loaded | UTorrentTorrentStatus.Checked, DownloadItemStatus.Completed, false)]
[TestCase(UTorrentTorrentStatus.Loaded | UTorrentTorrentStatus.Checked | UTorrentTorrentStatus.Queued, DownloadItemStatus.Completed, true)]
[TestCase(UTorrentTorrentStatus.Loaded | UTorrentTorrentStatus.Checked | UTorrentTorrentStatus.Started, DownloadItemStatus.Completed, true)]
[TestCase(UTorrentTorrentStatus.Loaded | UTorrentTorrentStatus.Checked | UTorrentTorrentStatus.Queued | UTorrentTorrentStatus.Paused, DownloadItemStatus.Completed, true)]
public void GetItems_should_return_completed_item_as_downloadItemStatus(UTorrentTorrentStatus apiStatus, DownloadItemStatus expectedItemStatus, bool expectedReadOnly)
[TestCase(UTorrentTorrentStatus.Loaded | UTorrentTorrentStatus.Checking, DownloadItemStatus.Queued, true)]
[TestCase(UTorrentTorrentStatus.Loaded | UTorrentTorrentStatus.Checked, DownloadItemStatus.Completed, true)]
[TestCase(UTorrentTorrentStatus.Loaded | UTorrentTorrentStatus.Checked | UTorrentTorrentStatus.Queued, DownloadItemStatus.Completed, false)]
[TestCase(UTorrentTorrentStatus.Loaded | UTorrentTorrentStatus.Checked | UTorrentTorrentStatus.Started, DownloadItemStatus.Completed, false)]
[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 expectedValue)
{
_completed.Status = apiStatus;
@ -306,7 +306,8 @@ public void GetItems_should_return_completed_item_as_downloadItemStatus(UTorrent
var item = Subject.GetItems().Single();
item.Status.Should().Be(expectedItemStatus);
item.IsReadOnly.Should().Be(expectedReadOnly);
item.CanBeRemoved.Should().Be(expectedValue);
item.CanMoveFiles.Should().Be(expectedValue);
}
[Test]

View File

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

View File

@ -81,10 +81,10 @@ public void should_use_file_name_for_source_title_if_scene_name_is_null()
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>()
.Verify(v => v.Insert(It.Is<History.History>(h => h.SourceTitle == Path.GetFileNameWithoutExtension(localEpisode.Path))));
}
}
}
}

View File

@ -224,9 +224,9 @@ public void should_import_larger_files_first()
}
[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>()
.Verify(v => v.UpgradeEpisodeFile(It.IsAny<EpisodeFile>(), _approvedDecisions.First().LocalEpisode, true), Times.Once());
@ -235,7 +235,7 @@ public void should_copy_readonly_downloads()
[Test]
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>()
.Verify(v => v.UpgradeEpisodeFile(It.IsAny<EpisodeFile>(), _approvedDecisions.First().LocalEpisode, false), Times.Once());

View File

@ -103,7 +103,8 @@ public override IEnumerable<DownloadClientItem> GetItems()
Status = item.Status,
IsReadOnly = Settings.ReadOnly
CanMoveFiles = !Settings.ReadOnly,
CanBeRemoved = !Settings.ReadOnly
};
}
}

View File

@ -68,7 +68,10 @@ public override IEnumerable<DownloadClientItem> GetItems()
OutputPath = item.OutputPath,
Status = item.Status
Status = item.Status,
CanBeRemoved = true,
CanMoveFiles = true
};
}
}

View File

@ -138,14 +138,7 @@ public override IEnumerable<DownloadClientItem> GetItems()
}
// 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.IsReadOnly = false;
}
else
{
item.IsReadOnly = true;
}
item.CanMoveFiles = item.CanBeRemoved = (torrent.IsAutoManaged && torrent.StopAtRatio && torrent.Ratio >= torrent.StopRatio && torrent.State == DelugeTorrentStatus.Paused);
items.Add(item);
}
@ -178,7 +171,7 @@ public override DownloadClientStatus GetStatus()
{
status.OutputRootFolders = new List<OsPath> { _remotePathMappingService.RemapRemoteToLocal(Settings.Host, destDir) };
}
return status;
}

View File

@ -90,7 +90,8 @@ public override IEnumerable<DownloadClientItem> GetItems()
RemainingTime = GetRemainingTime(torrent),
Status = GetStatus(torrent),
Message = GetMessage(torrent),
IsReadOnly = !IsFinished(torrent)
CanMoveFiles = IsCompleted(torrent),
CanBeRemoved = IsFinished(torrent)
};
if (item.Status == DownloadItemStatus.Completed || item.Status == DownloadItemStatus.Failed)
@ -199,6 +200,11 @@ protected bool IsFinished(DownloadStationTask torrent)
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)
{
if (torrent.StatusExtra != null)

View File

@ -99,7 +99,8 @@ public override IEnumerable<DownloadClientItem> GetItems()
RemainingSize = taskRemainingSize,
Status = GetStatus(nzb),
Message = GetMessage(nzb),
IsReadOnly = !IsFinished(nzb)
CanBeRemoved = true,
CanMoveFiles = true
};
if (item.Status != DownloadItemStatus.Paused)
@ -291,11 +292,6 @@ protected ValidationFailure ValidateVersion()
return null;
}
protected bool IsFinished(DownloadStationTask task)
{
return task.Status == DownloadStationTaskStatus.Finished;
}
protected string GetMessage(DownloadStationTask task)
{
if (task.StatusExtra != null)

View File

@ -97,14 +97,7 @@ public override IEnumerable<DownloadClientItem> GetItems()
item.Status = DownloadItemStatus.Downloading;
}
if (torrent.IsFinished && torrent.State == HadoukenTorrentState.Paused)
{
item.IsReadOnly = false;
}
else
{
item.IsReadOnly = true;
}
item.CanMoveFiles = item.CanBeRemoved = (torrent.IsFinished && torrent.State == HadoukenTorrentState.Paused);
items.Add(item);
}
@ -170,7 +163,7 @@ private ValidationFailure TestConnection()
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)

View File

@ -72,7 +72,9 @@ public override IEnumerable<DownloadClientItem> GetItems()
queueItem.TotalSize = vortexQueueItem.TotalDownloadSize;
queueItem.RemainingSize = vortexQueueItem.TotalDownloadSize - vortexQueueItem.DownloadedSize;
queueItem.RemainingTime = null;
queueItem.CanBeRemoved = true;
queueItem.CanMoveFiles = true;
if (vortexQueueItem.IsPaused)
{
queueItem.Status = DownloadItemStatus.Paused;
@ -132,7 +134,7 @@ public override void RemoveItem(string downloadId, bool deleteData)
{
_proxy.Remove(queueItem.Id, deleteData, Settings);
}
}
}
}
protected List<NzbVortexGroup> GetGroups()
@ -256,4 +258,4 @@ private OsPath GetOutputPath(NzbVortexQueueItem vortexQueueItem, DownloadClientI
return new OsPath(Path.Combine(outputPath.FullPath, filesResponse.First().FileName));
}
}
}
}

View File

@ -83,6 +83,8 @@ private IEnumerable<DownloadClientItem> GetQueue()
queueItem.TotalSize = totalSize;
queueItem.Category = item.Category;
queueItem.DownloadClient = Definition.Name;
queueItem.CanMoveFiles = true;
queueItem.CanBeRemoved = true;
if (globalStatus.DownloadPaused || remainingSize == pausedSize && remainingSize != 0)
{

View File

@ -77,6 +77,9 @@ public override IEnumerable<DownloadClientItem> GetItems()
DownloadId = GetDownloadClientId(file),
Title = title,
CanBeRemoved = true,
CanMoveFiles = true,
TotalSize = _diskProvider.GetFileSize(file),
OutputPath = new OsPath(file)

View File

@ -106,7 +106,7 @@ public override IEnumerable<DownloadClientItem> GetItems()
// 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).
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)
{
@ -129,7 +129,7 @@ public override IEnumerable<DownloadClientItem> GetItems()
item.Status = DownloadItemStatus.Queued;
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 "stalledUP": // torrent is being seeded, but no connection were made
case "queuedUP": // queuing is enabled and torrent is queued for upload

View File

@ -78,6 +78,8 @@ private IEnumerable<DownloadClientItem> GetQueue()
queueItem.TotalSize = (long)(sabQueueItem.Size * 1024 * 1024);
queueItem.RemainingSize = (long)(sabQueueItem.Sizeleft * 1024 * 1024);
queueItem.RemainingTime = sabQueueItem.Timeleft;
queueItem.CanBeRemoved = true;
queueItem.CanMoveFiles = true;
if (sabQueue.Paused || sabQueueItem.Status == SabnzbdDownloadStatus.Paused)
{

View File

@ -105,7 +105,7 @@ public override IEnumerable<DownloadClientItem> GetItems()
item.Status = DownloadItemStatus.Downloading;
}
item.IsReadOnly = torrent.Status != TransmissionTorrentStatus.Stopped;
item.CanMoveFiles = item.CanBeRemoved = torrent.Status == TransmissionTorrentStatus.Stopped;
items.Add(item);
}
@ -122,7 +122,7 @@ public override DownloadClientStatus GetStatus()
{
var config = _proxy.GetConfig(Settings);
var destDir = config.GetValueOrDefault("download-dir") as string;
if (Settings.TvCategory.IsNotNullOrWhiteSpace())
{
destDir = string.Format("{0}/.{1}", destDir, Settings.TvCategory);
@ -246,4 +246,4 @@ private ValidationFailure TestGetTorrents()
return null;
}
}
}
}

View File

@ -107,19 +107,31 @@ public override IEnumerable<DownloadClientItem> GetItems()
item.RemainingSize = torrent.RemainingSize;
item.Category = torrent.Category;
if (torrent.DownRate > 0) {
if (torrent.DownRate > 0)
{
var secondsLeft = torrent.RemainingSize / torrent.DownRate;
item.RemainingTime = TimeSpan.FromSeconds(secondsLeft);
} else {
}
else
{
item.RemainingTime = TimeSpan.Zero;
}
if (torrent.IsFinished) item.Status = DownloadItemStatus.Completed;
else if (torrent.IsActive) item.Status = DownloadItemStatus.Downloading;
else if (!torrent.IsActive) item.Status = DownloadItemStatus.Paused;
if (torrent.IsFinished)
{
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
item.IsReadOnly = true;
item.CanMoveFiles = item.CanBeRemoved = false;
items.Add(item);
}

View File

@ -165,7 +165,7 @@ public override IEnumerable<DownloadClientItem> GetItems()
}
// '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);
}

View File

@ -21,7 +21,9 @@ public class DownloadClientItem
public DownloadItemStatus Status { 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; }
}

View File

@ -37,7 +37,7 @@ public void Handle(DownloadCompletedEvent message)
{
if (!_configService.RemoveCompletedDownloads ||
message.TrackedDownload.DownloadItem.Removed ||
message.TrackedDownload.DownloadItem.IsReadOnly ||
!message.TrackedDownload.DownloadItem.CanBeRemoved ||
message.TrackedDownload.DownloadItem.Status == DownloadItemStatus.Downloading)
{
return;
@ -50,7 +50,7 @@ public void Handle(DownloadFailedEvent message)
{
var trackedDownload = message.TrackedDownload;
if (trackedDownload == null || trackedDownload.DownloadItem.IsReadOnly || _configService.RemoveFailedDownloads == false)
if (trackedDownload == null || !trackedDownload.DownloadItem.CanBeRemoved || _configService.RemoveFailedDownloads == false)
{
return;
}
@ -78,4 +78,4 @@ private void RemoveFromDownloadClient(TrackedDownload trackedDownload)
}
}
}
}
}

View File

@ -64,7 +64,7 @@ private void Refresh()
{
var clientTrackedDownloads = ProcessClientDownloads(downloadClient);
// Only track completed downloads if
// Only track completed downloads if
trackedDownloads.AddRange(clientTrackedDownloads.Where(DownloadIsTrackable));
}
@ -107,7 +107,7 @@ private List<TrackedDownload> ProcessClientDownloads(IDownloadClient downloadCli
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));
}

View File

@ -185,7 +185,7 @@ private List<ImportResult> ProcessFolder(DirectoryInfo directoryInfo, ImportMode
var decisions = _importDecisionMaker.GetImportDecisions(videoFiles.ToList(), series, folderInfo, true);
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) &&
ShouldDeleteFolder(directoryInfo, series))
{

View File

@ -90,7 +90,7 @@ public List<ImportResult> Import(List<ImportDecision> decisions, bool newDownloa
{
default:
case ImportMode.Auto:
copyOnly = downloadClientItem != null && downloadClientItem.IsReadOnly;
copyOnly = downloadClientItem != null && !downloadClientItem.CanMoveFiles;
break;
case ImportMode.Move:
copyOnly = false;
@ -122,7 +122,7 @@ public List<ImportResult> Import(List<ImportDecision> decisions, bool newDownloa
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
{

View File

@ -251,7 +251,7 @@ public void Execute(ManualImportCommand message)
{
if (_downloadedEpisodesImportService.ShouldDeleteFolder(
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);
}

View File

@ -10,7 +10,7 @@ public class EpisodeImportedEvent : IEvent
public bool NewDownload { get; private set; }
public string DownloadClient { 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)
{
@ -19,14 +19,14 @@ public EpisodeImportedEvent(LocalEpisode episodeInfo, EpisodeFile importedEpisod
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;
ImportedEpisode = importedEpisode;
NewDownload = newDownload;
DownloadClient = downloadClient;
DownloadId = downloadId;
IsReadOnly = isReadOnly;
// IsReadOnly = isReadOnly;
}
}
}
}