diff --git a/src/NzbDrone.Common/NzbDrone.Common.csproj b/src/NzbDrone.Common/NzbDrone.Common.csproj
index ac0c62da3..17c5cf6d0 100644
--- a/src/NzbDrone.Common/NzbDrone.Common.csproj
+++ b/src/NzbDrone.Common/NzbDrone.Common.csproj
@@ -217,6 +217,7 @@
+
@@ -254,11 +255,11 @@
-
\ No newline at end of file
diff --git a/src/NzbDrone.Common/Serializer/UnderscoreStringEnumConverter.cs b/src/NzbDrone.Common/Serializer/UnderscoreStringEnumConverter.cs
new file mode 100644
index 000000000..9022c029f
--- /dev/null
+++ b/src/NzbDrone.Common/Serializer/UnderscoreStringEnumConverter.cs
@@ -0,0 +1,58 @@
+using System;
+using System.Text;
+using Newtonsoft.Json;
+
+namespace NzbDrone.Common.Serializer
+{
+ public class UnderscoreStringEnumConverter : JsonConverter
+ {
+ public object UnknownValue { get; set; }
+
+ public UnderscoreStringEnumConverter(object unknownValue)
+ {
+ UnknownValue = unknownValue;
+ }
+
+ public override bool CanConvert(Type objectType)
+ {
+ return objectType.IsEnum;
+ }
+
+ public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
+ {
+ var enumString = reader.Value.ToString().Replace("_", string.Empty);
+
+ try
+ {
+ return Enum.Parse(objectType, enumString, true);
+ }
+ catch
+ {
+ if (UnknownValue == null)
+ {
+ throw;
+ }
+
+ return UnknownValue;
+ }
+ }
+
+ public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
+ {
+ var enumText = value.ToString();
+ var builder = new StringBuilder(enumText.Length + 4);
+ builder.Append(char.ToLower(enumText[0]));
+ for (int i = 1; i < enumText.Length; i++)
+ {
+ if (char.IsUpper(enumText[i]))
+ {
+ builder.Append('_');
+ }
+ builder.Append(char.ToLower(enumText[i]));
+ }
+ enumText = builder.ToString();
+
+ writer.WriteValue(enumText);
+ }
+ }
+}
diff --git a/src/NzbDrone.Core.Test/Download/DownloadClientTests/DelugeTests/DelugeFixture.cs b/src/NzbDrone.Core.Test/Download/DownloadClientTests/DelugeTests/DelugeFixture.cs
index 27da14d54..39577835e 100644
--- a/src/NzbDrone.Core.Test/Download/DownloadClientTests/DelugeTests/DelugeFixture.cs
+++ b/src/NzbDrone.Core.Test/Download/DownloadClientTests/DelugeTests/DelugeFixture.cs
@@ -19,6 +19,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DelugeTests
protected DelugeTorrent _downloading;
protected DelugeTorrent _failed;
protected DelugeTorrent _completed;
+ protected DelugeTorrent _seeding;
[SetUp]
public void Setup()
@@ -75,7 +76,11 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DelugeTests
Size = 1000,
BytesDownloaded = 1000,
Progress = 100.0,
- DownloadPath = "somepath"
+ DownloadPath = "somepath",
+ IsAutoManaged = true,
+ StopAtRatio = true,
+ StopRatio = 1.0,
+ Ratio = 1.5
};
Mocker.GetMock()
@@ -189,6 +194,9 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DelugeTests
PrepareClientToReturnCompletedItem();
var item = Subject.GetItems().Single();
VerifyCompleted(item);
+
+ item.CanBeRemoved.Should().BeTrue();
+ item.CanMoveFiles.Should().BeTrue();
}
[Test]
@@ -248,11 +256,11 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DelugeTests
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)]
+ [TestCase(DelugeTorrentStatus.Checking, DownloadItemStatus.Downloading)]
+ [TestCase(DelugeTorrentStatus.Queued, DownloadItemStatus.Completed)]
+ [TestCase(DelugeTorrentStatus.Seeding, DownloadItemStatus.Completed)]
+ public void GetItems_should_return_completed_item_as_downloadItemStatus(string apiStatus, DownloadItemStatus expectedItemStatus)
{
_completed.State = apiStatus;
@@ -261,24 +269,25 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DelugeTests
var item = Subject.GetItems().Single();
item.Status.Should().Be(expectedItemStatus);
- item.IsReadOnly.Should().Be(expectedReadOnly);
}
- [Test]
- public void GetItems_should_check_share_ratio_for_readonly()
+ [TestCase(0.5, false)]
+ [TestCase(1.01, true)]
+ public void GetItems_should_check_share_ratio_for_moveFiles_and_remove(double ratio, bool canBeRemoved)
{
_completed.State = DelugeTorrentStatus.Paused;
_completed.IsAutoManaged = true;
_completed.StopAtRatio = true;
_completed.StopRatio = 1.0;
- _completed.Ratio = 1.01;
+ _completed.Ratio = ratio;
PrepareClientToReturnCompletedItem();
var item = Subject.GetItems().Single();
item.Status.Should().Be(DownloadItemStatus.Completed);
- item.IsReadOnly.Should().BeFalse();
+ item.CanMoveFiles.Should().Be(canBeRemoved);
+ item.CanBeRemoved.Should().Be(canBeRemoved);
}
[Test]
diff --git a/src/NzbDrone.Core.Test/Download/DownloadClientTests/DownloadStationTests/DownloadStationsTaskStatusJsonConverterFixture.cs b/src/NzbDrone.Core.Test/Download/DownloadClientTests/DownloadStationTests/DownloadStationsTaskStatusJsonConverterFixture.cs
new file mode 100644
index 000000000..0ad41bbfd
--- /dev/null
+++ b/src/NzbDrone.Core.Test/Download/DownloadClientTests/DownloadStationTests/DownloadStationsTaskStatusJsonConverterFixture.cs
@@ -0,0 +1,49 @@
+using FluentAssertions;
+using Newtonsoft.Json;
+using NUnit.Framework;
+using NzbDrone.Core.Download.Clients.DownloadStation;
+
+namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests
+{
+ [TestFixture]
+ public class DownloadStationsTaskStatusJsonConverterFixture
+ {
+ [TestCase("captcha_needed", DownloadStationTaskStatus.CaptchaNeeded)]
+ [TestCase("filehosting_waiting", DownloadStationTaskStatus.FilehostingWaiting)]
+ [TestCase("hash_checking", DownloadStationTaskStatus.HashChecking)]
+ [TestCase("error", DownloadStationTaskStatus.Error)]
+ [TestCase("downloading", DownloadStationTaskStatus.Downloading)]
+ public void should_parse_enum_correctly(string value, DownloadStationTaskStatus expected)
+ {
+ var task = "{\"Status\": \"" + value + "\"}";
+
+ var item = JsonConvert.DeserializeObject(task);
+
+ item.Status.Should().Be(expected);
+ }
+
+ [TestCase("captcha_needed", DownloadStationTaskStatus.CaptchaNeeded)]
+ [TestCase("filehosting_waiting", DownloadStationTaskStatus.FilehostingWaiting)]
+ [TestCase("hash_checking", DownloadStationTaskStatus.HashChecking)]
+ [TestCase("error", DownloadStationTaskStatus.Error)]
+ [TestCase("downloading", DownloadStationTaskStatus.Downloading)]
+ public void should_serialize_enum_correctly(string expected, DownloadStationTaskStatus value)
+ {
+ var task = new DownloadStationTask { Status = value };
+
+ var item = JsonConvert.SerializeObject(task);
+
+ item.Should().Contain(expected);
+ }
+
+ [Test]
+ public void should_return_unknown_if_unknown_enum_value()
+ {
+ var task = "{\"Status\": \"some_unknown_value\"}";
+
+ var item = JsonConvert.DeserializeObject(task);
+
+ item.Status.Should().Be(DownloadStationTaskStatus.Unknown);
+ }
+ }
+}
diff --git a/src/NzbDrone.Core.Test/Download/DownloadClientTests/DownloadStationTests/TorrentDownloadStationFixture.cs b/src/NzbDrone.Core.Test/Download/DownloadClientTests/DownloadStationTests/TorrentDownloadStationFixture.cs
index 58aa5700e..c4e396965 100644
--- a/src/NzbDrone.Core.Test/Download/DownloadClientTests/DownloadStationTests/TorrentDownloadStationFixture.cs
+++ b/src/NzbDrone.Core.Test/Download/DownloadClientTests/DownloadStationTests/TorrentDownloadStationFixture.cs
@@ -576,11 +576,11 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests
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 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests
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)]
@@ -601,9 +605,12 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests
[TestCase(DownloadStationTaskStatus.Finished, DownloadItemStatus.Completed)]
[TestCase(DownloadStationTaskStatus.Finishing, DownloadItemStatus.Downloading)]
[TestCase(DownloadStationTaskStatus.HashChecking, DownloadItemStatus.Downloading)]
+ [TestCase(DownloadStationTaskStatus.CaptchaNeeded, DownloadItemStatus.Downloading)]
[TestCase(DownloadStationTaskStatus.Paused, DownloadItemStatus.Paused)]
[TestCase(DownloadStationTaskStatus.Seeding, DownloadItemStatus.Completed)]
+ [TestCase(DownloadStationTaskStatus.FilehostingWaiting, DownloadItemStatus.Queued)]
[TestCase(DownloadStationTaskStatus.Waiting, DownloadItemStatus.Queued)]
+ [TestCase(DownloadStationTaskStatus.Unknown, DownloadItemStatus.Queued)]
public void GetItems_should_return_item_as_downloadItemStatus(DownloadStationTaskStatus apiStatus, DownloadItemStatus expectedItemStatus)
{
GivenSerialNumber();
diff --git a/src/NzbDrone.Core.Test/Download/DownloadClientTests/DownloadStationTests/UsenetDownloadStationFixture.cs b/src/NzbDrone.Core.Test/Download/DownloadClientTests/DownloadStationTests/UsenetDownloadStationFixture.cs
index 52fc2ee30..fafdddaa7 100644
--- a/src/NzbDrone.Core.Test/Download/DownloadClientTests/DownloadStationTests/UsenetDownloadStationFixture.cs
+++ b/src/NzbDrone.Core.Test/Download/DownloadClientTests/DownloadStationTests/UsenetDownloadStationFixture.cs
@@ -408,32 +408,18 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests
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() { _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)]
[TestCase(DownloadStationTaskStatus.Finished, DownloadItemStatus.Completed)]
[TestCase(DownloadStationTaskStatus.Finishing, DownloadItemStatus.Downloading)]
[TestCase(DownloadStationTaskStatus.HashChecking, DownloadItemStatus.Downloading)]
+ [TestCase(DownloadStationTaskStatus.CaptchaNeeded, DownloadItemStatus.Downloading)]
[TestCase(DownloadStationTaskStatus.Paused, DownloadItemStatus.Paused)]
+ [TestCase(DownloadStationTaskStatus.Seeding, DownloadItemStatus.Completed)]
+ [TestCase(DownloadStationTaskStatus.FilehostingWaiting, DownloadItemStatus.Queued)]
[TestCase(DownloadStationTaskStatus.Waiting, DownloadItemStatus.Queued)]
+ [TestCase(DownloadStationTaskStatus.Unknown, DownloadItemStatus.Queued)]
public void GetItems_should_return_item_as_downloadItemStatus(DownloadStationTaskStatus apiStatus, DownloadItemStatus expectedItemStatus)
{
GivenSerialNumber();
diff --git a/src/NzbDrone.Core.Test/Download/DownloadClientTests/QBittorrentTests/QBittorrentFixture.cs b/src/NzbDrone.Core.Test/Download/DownloadClientTests/QBittorrentTests/QBittorrentFixture.cs
index afef62690..d7ff95b83 100644
--- a/src/NzbDrone.Core.Test/Download/DownloadClientTests/QBittorrentTests/QBittorrentFixture.cs
+++ b/src/NzbDrone.Core.Test/Download/DownloadClientTests/QBittorrentTests/QBittorrentFixture.cs
@@ -311,7 +311,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.QBittorrentTests
}
[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 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.QBittorrentTests
GivenTorrents(new List { 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 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.QBittorrentTests
GivenTorrents(new List { 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 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.QBittorrentTests
GivenTorrents(new List { 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 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.QBittorrentTests
GivenTorrents(new List { torrent });
var item = Subject.GetItems().Single();
- item.IsReadOnly.Should().BeFalse();
+ item.CanBeRemoved.Should().BeTrue();
+ item.CanMoveFiles.Should().BeTrue();
}
[Test]
diff --git a/src/NzbDrone.Core.Test/Download/DownloadClientTests/TransmissionTests/TransmissionFixture.cs b/src/NzbDrone.Core.Test/Download/DownloadClientTests/TransmissionTests/TransmissionFixture.cs
index 0ecf0ddcc..65acb57f7 100644
--- a/src/NzbDrone.Core.Test/Download/DownloadClientTests/TransmissionTests/TransmissionFixture.cs
+++ b/src/NzbDrone.Core.Test/Download/DownloadClientTests/TransmissionTests/TransmissionFixture.cs
@@ -41,6 +41,9 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.TransmissionTests
PrepareClientToReturnCompletedItem();
var item = Subject.GetItems().Single();
VerifyCompleted(item);
+
+ item.CanBeRemoved.Should().BeTrue();
+ item.CanMoveFiles.Should().BeTrue();
}
[Test]
@@ -172,13 +175,13 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.TransmissionTests
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 +190,8 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.TransmissionTests
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]
diff --git a/src/NzbDrone.Core.Test/Download/DownloadClientTests/UTorrentTests/UTorrentFixture.cs b/src/NzbDrone.Core.Test/Download/DownloadClientTests/UTorrentTests/UTorrentFixture.cs
index 0a96371fe..11551917c 100644
--- a/src/NzbDrone.Core.Test/Download/DownloadClientTests/UTorrentTests/UTorrentFixture.cs
+++ b/src/NzbDrone.Core.Test/Download/DownloadClientTests/UTorrentTests/UTorrentFixture.cs
@@ -222,6 +222,9 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.UTorrentTests
PrepareClientToReturnCompletedItem();
var item = Subject.GetItems().Single();
VerifyCompleted(item);
+
+ item.CanBeRemoved.Should().BeTrue();
+ item.CanMoveFiles.Should().BeTrue();
}
[Test]
@@ -292,12 +295,12 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.UTorrentTests
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 +309,8 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.UTorrentTests
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]
diff --git a/src/NzbDrone.Core.Test/Download/DownloadClientTests/VuzeTests/VuzeFixture.cs b/src/NzbDrone.Core.Test/Download/DownloadClientTests/VuzeTests/VuzeFixture.cs
index 8a1108656..2884581c6 100644
--- a/src/NzbDrone.Core.Test/Download/DownloadClientTests/VuzeTests/VuzeFixture.cs
+++ b/src/NzbDrone.Core.Test/Download/DownloadClientTests/VuzeTests/VuzeFixture.cs
@@ -181,12 +181,12 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.VuzeTests
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.Queued, true)]
- [TestCase(TransmissionTorrentStatus.SeedingWait, DownloadItemStatus.Completed, true)]
- [TestCase(TransmissionTorrentStatus.Seeding, DownloadItemStatus.Completed, true)]
+ [TestCase(TransmissionTorrentStatus.Stopped, DownloadItemStatus.Completed, true)]
+ [TestCase(TransmissionTorrentStatus.CheckWait, DownloadItemStatus.Downloading, false)]
+ [TestCase(TransmissionTorrentStatus.Check, DownloadItemStatus.Downloading, false)]
+ [TestCase(TransmissionTorrentStatus.Queued, DownloadItemStatus.Queued, 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 expectedReadOnly)
{
_completed.Status = apiStatus;
@@ -196,7 +196,8 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.VuzeTests
var item = Subject.GetItems().Single();
item.Status.Should().Be(expectedItemStatus);
- item.IsReadOnly.Should().Be(expectedReadOnly);
+ item.CanBeRemoved.Should().Be(expectedReadOnly);
+ item.CanMoveFiles.Should().Be(expectedReadOnly);
}
[Test]
diff --git a/src/NzbDrone.Core.Test/HistoryTests/HistoryServiceFixture.cs b/src/NzbDrone.Core.Test/HistoryTests/HistoryServiceFixture.cs
index 9619e4a50..c95a34196 100644
--- a/src/NzbDrone.Core.Test/HistoryTests/HistoryServiceFixture.cs
+++ b/src/NzbDrone.Core.Test/HistoryTests/HistoryServiceFixture.cs
@@ -81,7 +81,7 @@ namespace NzbDrone.Core.Test.HistoryTests
Path = @"C:\Test\Unsorted\Movie.2011.mkv"
};
- Subject.Handle(new MovieImportedEvent(localMovie, movieFile, true, "sab", "abcd", true));
+ Subject.Handle(new MovieImportedEvent(localMovie, movieFile, true, "sab", "abcd"));
Mocker.GetMock()
.Verify(v => v.Insert(It.Is(h => h.SourceTitle == Path.GetFileNameWithoutExtension(localMovie.Path))));
diff --git a/src/NzbDrone.Core.Test/MediaFiles/ImportApprovedEpisodesFixture.cs b/src/NzbDrone.Core.Test/MediaFiles/ImportApprovedEpisodesFixture.cs
index 2b7440e90..55c0c4918 100644
--- a/src/NzbDrone.Core.Test/MediaFiles/ImportApprovedEpisodesFixture.cs
+++ b/src/NzbDrone.Core.Test/MediaFiles/ImportApprovedEpisodesFixture.cs
@@ -218,9 +218,9 @@ namespace NzbDrone.Core.Test.MediaFiles
}
[Test]
- public void should_copy_readonly_downloads()
+ public void should_copy_when_cannot_move_files_downloads()
{
- Subject.Import(new List { _approvedDecisions.First() }, true, new DownloadClientItem { Title = "30.Rock.S01E01", IsReadOnly = true });
+ Subject.Import(new List { _approvedDecisions.First() }, true, new DownloadClientItem { Title = "30.Rock.S01E01", CanMoveFiles = false});
Mocker.GetMock()
.Verify(v => v.UpgradeMovieFile(It.IsAny(), _approvedDecisions.First().LocalMovie, true), Times.Once());
@@ -229,7 +229,7 @@ namespace NzbDrone.Core.Test.MediaFiles
[Test]
public void should_use_override_importmode()
{
- Subject.Import(new List { _approvedDecisions.First() }, true, new DownloadClientItem { Title = "30.Rock.S01E01", IsReadOnly = true }, ImportMode.Move);
+ Subject.Import(new List { _approvedDecisions.First() }, true, new DownloadClientItem { Title = "30.Rock.S01E01", CanMoveFiles = false }, ImportMode.Move);
Mocker.GetMock()
.Verify(v => v.UpgradeMovieFile(It.IsAny(), _approvedDecisions.First().LocalMovie, false), Times.Once());
diff --git a/src/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj b/src/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj
index b1dac8d53..73541c02b 100644
--- a/src/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj
+++ b/src/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj
@@ -165,6 +165,7 @@
+
diff --git a/src/NzbDrone.Core/Download/Clients/Blackhole/TorrentBlackhole.cs b/src/NzbDrone.Core/Download/Clients/Blackhole/TorrentBlackhole.cs
index 7b0505f8e..d977d6ae5 100644
--- a/src/NzbDrone.Core/Download/Clients/Blackhole/TorrentBlackhole.cs
+++ b/src/NzbDrone.Core/Download/Clients/Blackhole/TorrentBlackhole.cs
@@ -103,7 +103,8 @@ namespace NzbDrone.Core.Download.Clients.Blackhole
Status = item.Status,
- IsReadOnly = Settings.ReadOnly
+ CanMoveFiles = !Settings.ReadOnly,
+ CanBeRemoved = !Settings.ReadOnly
};
}
}
diff --git a/src/NzbDrone.Core/Download/Clients/Deluge/Deluge.cs b/src/NzbDrone.Core/Download/Clients/Deluge/Deluge.cs
index 69b9a5c32..b5ca8c7f7 100644
--- a/src/NzbDrone.Core/Download/Clients/Deluge/Deluge.cs
+++ b/src/NzbDrone.Core/Download/Clients/Deluge/Deluge.cs
@@ -122,14 +122,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.
- 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);
}
diff --git a/src/NzbDrone.Core/Download/Clients/DownloadStation/DownloadStationTask.cs b/src/NzbDrone.Core/Download/Clients/DownloadStation/DownloadStationTask.cs
index a22cc7296..5b4a61253 100644
--- a/src/NzbDrone.Core/Download/Clients/DownloadStation/DownloadStationTask.cs
+++ b/src/NzbDrone.Core/Download/Clients/DownloadStation/DownloadStationTask.cs
@@ -1,7 +1,6 @@
-using System;
-using System.Collections.Generic;
+using System.Collections.Generic;
using Newtonsoft.Json;
-using Newtonsoft.Json.Converters;
+using NzbDrone.Common.Serializer;
namespace NzbDrone.Core.Download.Clients.DownloadStation
{
@@ -23,7 +22,7 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation
[JsonProperty(PropertyName = "status_extra")]
public Dictionary StatusExtra { get; set; }
- [JsonConverter(typeof(StringEnumConverter))]
+ [JsonConverter(typeof(UnderscoreStringEnumConverter), DownloadStationTaskStatus.Unknown)]
public DownloadStationTaskStatus Status { get; set; }
public DownloadStationTaskAdditional Additional { get; set; }
@@ -41,6 +40,7 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation
public enum DownloadStationTaskStatus
{
+ Unknown,
Waiting,
Downloading,
Paused,
@@ -48,9 +48,10 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation
Finished,
HashChecking,
Seeding,
- FileHostingWaiting,
+ FilehostingWaiting,
Extracting,
- Error
+ Error,
+ CaptchaNeeded
}
public enum DownloadStationPriority
diff --git a/src/NzbDrone.Core/Download/Clients/DownloadStation/Proxies/DiskStationProxyBase.cs b/src/NzbDrone.Core/Download/Clients/DownloadStation/Proxies/DiskStationProxyBase.cs
index 2a8e4b144..3dcb6dd1a 100644
--- a/src/NzbDrone.Core/Download/Clients/DownloadStation/Proxies/DiskStationProxyBase.cs
+++ b/src/NzbDrone.Core/Download/Clients/DownloadStation/Proxies/DiskStationProxyBase.cs
@@ -72,7 +72,20 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation.Proxies
DownloadStationSettings settings) where T : new()
{
var request = requestBuilder.Build();
- var response = _httpClient.Execute(request);
+ HttpResponse response;
+
+ try
+ {
+ response = _httpClient.Execute(request);
+ }
+ catch (HttpException ex)
+ {
+ throw new DownloadClientException("Unable to connect to Diskstation, please check your settings", ex);
+ }
+ catch (WebException ex)
+ {
+ throw new DownloadClientException("Unable to connect to Diskstation, please check your settings", ex);
+ }
_logger.Debug("Trying to {0}", operation);
diff --git a/src/NzbDrone.Core/Download/Clients/DownloadStation/TorrentDownloadStation.cs b/src/NzbDrone.Core/Download/Clients/DownloadStation/TorrentDownloadStation.cs
index a4291b7f1..9f77add30 100644
--- a/src/NzbDrone.Core/Download/Clients/DownloadStation/TorrentDownloadStation.cs
+++ b/src/NzbDrone.Core/Download/Clients/DownloadStation/TorrentDownloadStation.cs
@@ -90,7 +90,8 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation
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 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation
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)
@@ -221,7 +227,9 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation
{
switch (torrent.Status)
{
+ case DownloadStationTaskStatus.Unknown:
case DownloadStationTaskStatus.Waiting:
+ case DownloadStationTaskStatus.FilehostingWaiting:
return torrent.Size == 0 || GetRemainingSize(torrent) > 0 ? DownloadItemStatus.Queued : DownloadItemStatus.Completed;
case DownloadStationTaskStatus.Paused:
return DownloadItemStatus.Paused;
@@ -314,12 +322,12 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation
}
catch (DownloadClientAuthenticationException ex) // User could not have permission to access to downloadstation
{
- _logger.Error(ex);
+ _logger.Error(ex, ex.Message);
return new NzbDroneValidationFailure(string.Empty, ex.Message);
}
catch (Exception ex)
{
- _logger.Error(ex);
+ _logger.Error(ex, "Error testing Torrent Download Station");
return new NzbDroneValidationFailure(string.Empty, $"Unknown exception: {ex.Message}");
}
}
@@ -340,7 +348,7 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation
}
catch (WebException ex)
{
- _logger.Error(ex);
+ _logger.Error(ex, "Unable to connect to Torrent Download Station");
if (ex.Status == WebExceptionStatus.ConnectFailure)
{
@@ -353,7 +361,7 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation
}
catch (Exception ex)
{
- _logger.Error(ex);
+ _logger.Error(ex, "Error testing Torrent Download Station");
return new NzbDroneValidationFailure(string.Empty, $"Unknown exception: {ex.Message}");
}
}
diff --git a/src/NzbDrone.Core/Download/Clients/DownloadStation/UsenetDownloadStation.cs b/src/NzbDrone.Core/Download/Clients/DownloadStation/UsenetDownloadStation.cs
index 5c07c7c07..0f318f323 100644
--- a/src/NzbDrone.Core/Download/Clients/DownloadStation/UsenetDownloadStation.cs
+++ b/src/NzbDrone.Core/Download/Clients/DownloadStation/UsenetDownloadStation.cs
@@ -99,7 +99,8 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation
RemainingSize = taskRemainingSize,
Status = GetStatus(nzb),
Message = GetMessage(nzb),
- IsReadOnly = !IsFinished(nzb)
+ CanBeRemoved = true,
+ CanMoveFiles = true
};
if (item.Status != DownloadItemStatus.Paused)
@@ -233,12 +234,12 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation
}
catch (DownloadClientAuthenticationException ex) // User could not have permission to access to downloadstation
{
- _logger.Error(ex);
+ _logger.Error(ex, ex.Message);
return new NzbDroneValidationFailure(string.Empty, ex.Message);
}
catch (Exception ex)
{
- _logger.Error(ex);
+ _logger.Error(ex, "Error testing Usenet Download Station");
return new NzbDroneValidationFailure(string.Empty, $"Unknown exception: {ex.Message}");
}
}
@@ -259,7 +260,7 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation
}
catch (WebException ex)
{
- _logger.Error(ex);
+ _logger.Error(ex, "Unable to connect to Usenet Download Station");
if (ex.Status == WebExceptionStatus.ConnectFailure)
{
@@ -272,7 +273,7 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation
}
catch (Exception ex)
{
- _logger.Error(ex);
+ _logger.Error(ex, "Error testing Torrent Download Station");
return new NzbDroneValidationFailure(string.Empty, "Unknown exception: " + ex.Message);
}
}
@@ -291,11 +292,6 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation
return null;
}
- protected bool IsFinished(DownloadStationTask task)
- {
- return task.Status == DownloadStationTaskStatus.Finished;
- }
-
protected string GetMessage(DownloadStationTask task)
{
if (task.StatusExtra != null)
@@ -318,7 +314,9 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation
{
switch (task.Status)
{
+ case DownloadStationTaskStatus.Unknown:
case DownloadStationTaskStatus.Waiting:
+ case DownloadStationTaskStatus.FilehostingWaiting:
return task.Size == 0 || GetRemainingSize(task) > 0 ? DownloadItemStatus.Queued : DownloadItemStatus.Completed;
case DownloadStationTaskStatus.Paused:
return DownloadItemStatus.Paused;
diff --git a/src/NzbDrone.Core/Download/Clients/Hadouken/Hadouken.cs b/src/NzbDrone.Core/Download/Clients/Hadouken/Hadouken.cs
index 3f364c5cf..1ef2a3f5f 100644
--- a/src/NzbDrone.Core/Download/Clients/Hadouken/Hadouken.cs
+++ b/src/NzbDrone.Core/Download/Clients/Hadouken/Hadouken.cs
@@ -97,14 +97,7 @@ namespace NzbDrone.Core.Download.Clients.Hadouken
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);
}
diff --git a/src/NzbDrone.Core/Download/Clients/NzbVortex/NzbVortex.cs b/src/NzbDrone.Core/Download/Clients/NzbVortex/NzbVortex.cs
index a33f21d84..1753aabda 100644
--- a/src/NzbDrone.Core/Download/Clients/NzbVortex/NzbVortex.cs
+++ b/src/NzbDrone.Core/Download/Clients/NzbVortex/NzbVortex.cs
@@ -72,7 +72,9 @@ namespace NzbDrone.Core.Download.Clients.NzbVortex
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;
diff --git a/src/NzbDrone.Core/Download/Clients/Nzbget/Nzbget.cs b/src/NzbDrone.Core/Download/Clients/Nzbget/Nzbget.cs
index a090760ac..8e697bf88 100644
--- a/src/NzbDrone.Core/Download/Clients/Nzbget/Nzbget.cs
+++ b/src/NzbDrone.Core/Download/Clients/Nzbget/Nzbget.cs
@@ -77,14 +77,15 @@ namespace NzbDrone.Core.Download.Clients.Nzbget
var droneParameter = item.Parameters.SingleOrDefault(p => p.Name == "drone");
- var queueItem = new DownloadClientItem()
- {
- DownloadId = droneParameter == null ? item.NzbId.ToString() : droneParameter.Value.ToString(),
- Title = item.NzbName,
- TotalSize = totalSize,
- Category = item.Category,
- DownloadClient = Definition.Name
- };
+ var queueItem = new DownloadClientItem();
+ queueItem.DownloadId = droneParameter == null ? item.NzbId.ToString() : droneParameter.Value.ToString();
+ queueItem.Title = item.NzbName;
+ queueItem.TotalSize = totalSize;
+ queueItem.Category = item.Category;
+ queueItem.DownloadClient = Definition.Name;
+ queueItem.CanMoveFiles = true;
+ queueItem.CanBeRemoved = true;
+
if (globalStatus.DownloadPaused || remainingSize == pausedSize && remainingSize != 0)
{
queueItem.Status = DownloadItemStatus.Paused;
@@ -136,18 +137,19 @@ namespace NzbDrone.Core.Download.Clients.Nzbget
{
var droneParameter = item.Parameters.SingleOrDefault(p => p.Name == "drone");
- var historyItem = new DownloadClientItem()
- {
- DownloadClient = Definition.Name,
- DownloadId = droneParameter == null ? item.Id.ToString() : droneParameter.Value.ToString(),
- Title = item.Name,
- TotalSize = MakeInt64(item.FileSizeHi, item.FileSizeLo),
- OutputPath = _remotePathMappingService.RemapRemoteToLocal(Settings.Host, new OsPath(item.DestDir)),
- Category = item.Category,
- 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}",
- Status = DownloadItemStatus.Completed,
- RemainingTime = TimeSpan.Zero
- };
+ var historyItem = new DownloadClientItem();
+ historyItem.DownloadClient = Definition.Name;
+ historyItem.DownloadId = droneParameter == null ? item.Id.ToString() : droneParameter.Value.ToString();
+ historyItem.Title = item.Name;
+ historyItem.TotalSize = MakeInt64(item.FileSizeHi, item.FileSizeLo);
+ historyItem.OutputPath = _remotePathMappingService.RemapRemoteToLocal(Settings.Host, new OsPath(item.DestDir));
+ historyItem.Category = item.Category;
+ 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.RemainingTime = TimeSpan.Zero;
+ historyItem.CanMoveFiles = true;
+ historyItem.CanBeRemoved = true;
+
if (item.DeleteStatus == "MANUAL")
{
continue;
diff --git a/src/NzbDrone.Core/Download/Clients/Pneumatic/Pneumatic.cs b/src/NzbDrone.Core/Download/Clients/Pneumatic/Pneumatic.cs
index 3ef1e5951..1d38046b6 100644
--- a/src/NzbDrone.Core/Download/Clients/Pneumatic/Pneumatic.cs
+++ b/src/NzbDrone.Core/Download/Clients/Pneumatic/Pneumatic.cs
@@ -78,6 +78,9 @@ namespace NzbDrone.Core.Download.Clients.Pneumatic
DownloadId = GetDownloadClientId(file),
Title = title,
+ CanBeRemoved = true,
+ CanMoveFiles = true,
+
TotalSize = _diskProvider.GetFileSize(file),
OutputPath = new OsPath(file)
diff --git a/src/NzbDrone.Core/Download/Clients/QBittorrent/QBittorrent.cs b/src/NzbDrone.Core/Download/Clients/QBittorrent/QBittorrent.cs
index a82b4f897..c1b10f3a1 100644
--- a/src/NzbDrone.Core/Download/Clients/QBittorrent/QBittorrent.cs
+++ b/src/NzbDrone.Core/Download/Clients/QBittorrent/QBittorrent.cs
@@ -94,7 +94,7 @@ namespace NzbDrone.Core.Download.Clients.QBittorrent
// 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)
{
diff --git a/src/NzbDrone.Core/Download/Clients/Sabnzbd/Sabnzbd.cs b/src/NzbDrone.Core/Download/Clients/Sabnzbd/Sabnzbd.cs
index bcfb368c2..8ed22975b 100644
--- a/src/NzbDrone.Core/Download/Clients/Sabnzbd/Sabnzbd.cs
+++ b/src/NzbDrone.Core/Download/Clients/Sabnzbd/Sabnzbd.cs
@@ -78,6 +78,8 @@ namespace NzbDrone.Core.Download.Clients.Sabnzbd
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)
{
@@ -142,7 +144,10 @@ namespace NzbDrone.Core.Download.Clients.Sabnzbd
RemainingSize = 0,
RemainingTime = TimeSpan.Zero,
- Message = sabHistoryItem.FailMessage
+ Message = sabHistoryItem.FailMessage,
+
+ CanBeRemoved = true,
+ CanMoveFiles = true
};
if (sabHistoryItem.Status == SabnzbdDownloadStatus.Failed)
diff --git a/src/NzbDrone.Core/Download/Clients/Transmission/TransmissionBase.cs b/src/NzbDrone.Core/Download/Clients/Transmission/TransmissionBase.cs
index 01e069849..a0af58dfd 100644
--- a/src/NzbDrone.Core/Download/Clients/Transmission/TransmissionBase.cs
+++ b/src/NzbDrone.Core/Download/Clients/Transmission/TransmissionBase.cs
@@ -106,7 +106,7 @@ namespace NzbDrone.Core.Download.Clients.Transmission
item.Status = DownloadItemStatus.Downloading;
}
- item.IsReadOnly = torrent.Status != TransmissionTorrentStatus.Stopped;
+ item.CanMoveFiles = item.CanBeRemoved = torrent.Status == TransmissionTorrentStatus.Stopped;
items.Add(item);
}
diff --git a/src/NzbDrone.Core/Download/Clients/rTorrent/RTorrent.cs b/src/NzbDrone.Core/Download/Clients/rTorrent/RTorrent.cs
index aa4db546a..c2ad6343d 100644
--- a/src/NzbDrone.Core/Download/Clients/rTorrent/RTorrent.cs
+++ b/src/NzbDrone.Core/Download/Clients/rTorrent/RTorrent.cs
@@ -115,7 +115,7 @@ namespace NzbDrone.Core.Download.Clients.RTorrent
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);
}
diff --git a/src/NzbDrone.Core/Download/Clients/uTorrent/UTorrent.cs b/src/NzbDrone.Core/Download/Clients/uTorrent/UTorrent.cs
index f6ab66d53..97e6509bb 100644
--- a/src/NzbDrone.Core/Download/Clients/uTorrent/UTorrent.cs
+++ b/src/NzbDrone.Core/Download/Clients/uTorrent/UTorrent.cs
@@ -169,7 +169,7 @@ namespace NzbDrone.Core.Download.Clients.UTorrent
}
// '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);
}
diff --git a/src/NzbDrone.Core/Download/DownloadClientItem.cs b/src/NzbDrone.Core/Download/DownloadClientItem.cs
index 2e0533e50..acd0b0579 100644
--- a/src/NzbDrone.Core/Download/DownloadClientItem.cs
+++ b/src/NzbDrone.Core/Download/DownloadClientItem.cs
@@ -21,7 +21,9 @@ namespace NzbDrone.Core.Download
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; }
}
diff --git a/src/NzbDrone.Core/Download/DownloadEventHub.cs b/src/NzbDrone.Core/Download/DownloadEventHub.cs
index 6d910292c..e6b08e20e 100644
--- a/src/NzbDrone.Core/Download/DownloadEventHub.cs
+++ b/src/NzbDrone.Core/Download/DownloadEventHub.cs
@@ -37,7 +37,7 @@ namespace NzbDrone.Core.Download
{
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 @@ namespace NzbDrone.Core.Download
{
var trackedDownload = message.TrackedDownload;
- if (trackedDownload == null || trackedDownload.DownloadItem.IsReadOnly || _configService.RemoveFailedDownloads == false)
+ if (trackedDownload == null || !trackedDownload.DownloadItem.CanBeRemoved || _configService.RemoveFailedDownloads == false)
{
return;
}
diff --git a/src/NzbDrone.Core/Download/TrackedDownloads/DownloadMonitoringService.cs b/src/NzbDrone.Core/Download/TrackedDownloads/DownloadMonitoringService.cs
index c4e887a14..1b1a6155b 100644
--- a/src/NzbDrone.Core/Download/TrackedDownloads/DownloadMonitoringService.cs
+++ b/src/NzbDrone.Core/Download/TrackedDownloads/DownloadMonitoringService.cs
@@ -107,7 +107,7 @@ namespace NzbDrone.Core.Download.TrackedDownloads
private void RemoveCompletedDownloads(List 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));
}
diff --git a/src/NzbDrone.Core/MediaFiles/DownloadedMovieImportService.cs b/src/NzbDrone.Core/MediaFiles/DownloadedMovieImportService.cs
index 4b39ca459..99957a181 100644
--- a/src/NzbDrone.Core/MediaFiles/DownloadedMovieImportService.cs
+++ b/src/NzbDrone.Core/MediaFiles/DownloadedMovieImportService.cs
@@ -191,7 +191,7 @@ namespace NzbDrone.Core.MediaFiles
var decisions = _importDecisionMaker.GetImportDecisions(videoFiles.ToList(), movie, null, folderInfo, true, false);
var importResults = _importApprovedMovie.Import(decisions, true, downloadClientItem, importMode);
- if ((downloadClientItem == null || !downloadClientItem.IsReadOnly) &&
+ if ((downloadClientItem == null || downloadClientItem.CanBeRemoved) &&
importResults.Any(i => i.Result == ImportResultType.Imported) &&
ShouldDeleteFolder(directoryInfo, movie))
{
diff --git a/src/NzbDrone.Core/MediaFiles/Events/MovieImportedEvent.cs b/src/NzbDrone.Core/MediaFiles/Events/MovieImportedEvent.cs
index bc26e83fa..d6061d244 100644
--- a/src/NzbDrone.Core/MediaFiles/Events/MovieImportedEvent.cs
+++ b/src/NzbDrone.Core/MediaFiles/Events/MovieImportedEvent.cs
@@ -9,8 +9,7 @@ namespace NzbDrone.Core.MediaFiles.Events
public MovieFile ImportedMovie { get; private set; }
public bool NewDownload { get; private set; }
public string DownloadClient { get; private set; }
- public string DownloadId { get; private set; }
- public bool IsReadOnly { get; set; }
+ public string DownloadId { get; private set; }
public MovieImportedEvent(LocalMovie movieInfo, MovieFile importedMovie, bool newDownload)
{
@@ -19,14 +18,13 @@ namespace NzbDrone.Core.MediaFiles.Events
NewDownload = newDownload;
}
- public MovieImportedEvent(LocalMovie movieInfo, MovieFile importedMovie, bool newDownload, string downloadClient, string downloadId, bool isReadOnly)
+ public MovieImportedEvent(LocalMovie movieInfo, MovieFile importedMovie, bool newDownload, string downloadClient, string downloadId)
{
MovieInfo = movieInfo;
ImportedMovie = importedMovie;
NewDownload = newDownload;
DownloadClient = downloadClient;
DownloadId = downloadId;
- IsReadOnly = isReadOnly;
}
}
}
diff --git a/src/NzbDrone.Core/MediaFiles/MovieImport/ImportApprovedMovie.cs b/src/NzbDrone.Core/MediaFiles/MovieImport/ImportApprovedMovie.cs
index da77655e7..a5b980e6a 100644
--- a/src/NzbDrone.Core/MediaFiles/MovieImport/ImportApprovedMovie.cs
+++ b/src/NzbDrone.Core/MediaFiles/MovieImport/ImportApprovedMovie.cs
@@ -93,7 +93,7 @@ namespace NzbDrone.Core.MediaFiles.MovieImport
{
default:
case ImportMode.Auto:
- copyOnly = downloadClientItem != null && downloadClientItem.IsReadOnly;
+ copyOnly = downloadClientItem != null && !downloadClientItem.CanMoveFiles;
break;
case ImportMode.Move:
copyOnly = false;
@@ -125,7 +125,7 @@ namespace NzbDrone.Core.MediaFiles.MovieImport
if (downloadClientItem != null)
{
- _eventAggregator.PublishEvent(new MovieImportedEvent(localMovie, movieFile, newDownload, downloadClientItem.DownloadClient, downloadClientItem.DownloadId, downloadClientItem.IsReadOnly));
+ _eventAggregator.PublishEvent(new MovieImportedEvent(localMovie, movieFile, newDownload, downloadClientItem.DownloadClient, downloadClientItem.DownloadId));
}
else
{
diff --git a/src/NzbDrone.Core/MediaFiles/MovieImport/Manual/ManualImportService.cs b/src/NzbDrone.Core/MediaFiles/MovieImport/Manual/ManualImportService.cs
index f22949885..12ea55fba 100644
--- a/src/NzbDrone.Core/MediaFiles/MovieImport/Manual/ManualImportService.cs
+++ b/src/NzbDrone.Core/MediaFiles/MovieImport/Manual/ManualImportService.cs
@@ -268,7 +268,7 @@ namespace NzbDrone.Core.MediaFiles.MovieImport.Manual
{
if (_downloadedMovieImportService.ShouldDeleteFolder(
new DirectoryInfo(trackedDownload.DownloadItem.OutputPath.FullPath),
- trackedDownload.RemoteMovie.Movie) && !trackedDownload.DownloadItem.IsReadOnly)
+ trackedDownload.RemoteMovie.Movie) && trackedDownload.DownloadItem.CanMoveFiles)
{
_diskProvider.DeleteFolder(trackedDownload.DownloadItem.OutputPath.FullPath, true);
}