Sonarr Pulls

'e4c341898
'5613ab05e
'372442af2
'28c45f941
'ea1616586
This commit is contained in:
Qstick 2017-09-25 22:31:52 -04:00
parent 482f8c1a61
commit ab9a9232cf
41 changed files with 247 additions and 179 deletions

View file

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

View file

@ -1,4 +1,4 @@

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

View file

@ -1,4 +1,4 @@
using System; using System;
using System.Linq; using System.Linq;
using System.Collections.Generic; using System.Collections.Generic;
using FluentAssertions; using FluentAssertions;
@ -19,6 +19,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DelugeTests
protected DelugeTorrent _downloading; protected DelugeTorrent _downloading;
protected DelugeTorrent _failed; protected DelugeTorrent _failed;
protected DelugeTorrent _completed; protected DelugeTorrent _completed;
protected DelugeTorrent _seeding;
[SetUp] [SetUp]
public void Setup() public void Setup()
@ -75,8 +76,12 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DelugeTests
Size = 1000, Size = 1000,
BytesDownloaded = 1000, BytesDownloaded = 1000,
Progress = 100.0, Progress = 100.0,
DownloadPath = "somepath" DownloadPath = "somepath",
}; IsAutoManaged = true,
StopAtRatio = true,
StopRatio = 1.0,
Ratio = 1.5
};
Mocker.GetMock<ITorrentFileInfoReader>() Mocker.GetMock<ITorrentFileInfoReader>()
.Setup(s => s.GetHashFromTorrentFile(It.IsAny<byte[]>())) .Setup(s => s.GetHashFromTorrentFile(It.IsAny<byte[]>()))
@ -189,6 +194,9 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DelugeTests
PrepareClientToReturnCompletedItem(); PrepareClientToReturnCompletedItem();
var item = Subject.GetItems().Single(); var item = Subject.GetItems().Single();
VerifyCompleted(item); VerifyCompleted(item);
item.CanBeRemoved.Should().BeTrue();
item.CanMoveFiles.Should().BeTrue();
} }
[Test] [Test]
@ -248,11 +256,11 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DelugeTests
item.Status.Should().Be(expectedItemStatus); item.Status.Should().Be(expectedItemStatus);
} }
[TestCase(DelugeTorrentStatus.Paused, DownloadItemStatus.Completed, true)] [TestCase(DelugeTorrentStatus.Paused, DownloadItemStatus.Completed)]
[TestCase(DelugeTorrentStatus.Checking, DownloadItemStatus.Downloading, true)] [TestCase(DelugeTorrentStatus.Checking, DownloadItemStatus.Downloading)]
[TestCase(DelugeTorrentStatus.Queued, DownloadItemStatus.Completed, true)] [TestCase(DelugeTorrentStatus.Queued, DownloadItemStatus.Completed)]
[TestCase(DelugeTorrentStatus.Seeding, DownloadItemStatus.Completed, true)] [TestCase(DelugeTorrentStatus.Seeding, DownloadItemStatus.Completed)]
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)
{ {
_completed.State = apiStatus; _completed.State = apiStatus;
@ -261,24 +269,25 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DelugeTests
var item = Subject.GetItems().Single(); var item = Subject.GetItems().Single();
item.Status.Should().Be(expectedItemStatus); item.Status.Should().Be(expectedItemStatus);
item.IsReadOnly.Should().Be(expectedReadOnly);
} }
[Test] [TestCase(0.5, false)]
public void GetItems_should_check_share_ratio_for_readonly() [TestCase(1.01, true)]
public void GetItems_should_check_share_ratio_for_moveFiles_and_remove(double ratio, bool canBeRemoved)
{ {
_completed.State = DelugeTorrentStatus.Paused; _completed.State = DelugeTorrentStatus.Paused;
_completed.IsAutoManaged = true; _completed.IsAutoManaged = true;
_completed.StopAtRatio = true; _completed.StopAtRatio = true;
_completed.StopRatio = 1.0; _completed.StopRatio = 1.0;
_completed.Ratio = 1.01; _completed.Ratio = ratio;
PrepareClientToReturnCompletedItem(); PrepareClientToReturnCompletedItem();
var item = Subject.GetItems().Single(); var item = Subject.GetItems().Single();
item.Status.Should().Be(DownloadItemStatus.Completed); item.Status.Should().Be(DownloadItemStatus.Completed);
item.IsReadOnly.Should().BeFalse(); item.CanMoveFiles.Should().Be(canBeRemoved);
item.CanBeRemoved.Should().Be(canBeRemoved);
} }
[Test] [Test]

View file

@ -1,4 +1,4 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using FluentAssertions; using FluentAssertions;
@ -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,10 @@ 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)]

View file

@ -1,4 +1,4 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using FluentAssertions; using FluentAssertions;
@ -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)]

View file

@ -1,4 +1,4 @@
using Moq; using Moq;
using NUnit.Framework; using NUnit.Framework;
using NzbDrone.Common.Http; using NzbDrone.Common.Http;
using NzbDrone.Core.Download; using NzbDrone.Core.Download;
@ -190,6 +190,9 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.HadoukenTests
PrepareClientToReturnCompletedItem(); PrepareClientToReturnCompletedItem();
var item = Subject.GetItems().Single(); var item = Subject.GetItems().Single();
VerifyCompleted(item); VerifyCompleted(item);
item.CanBeRemoved.Should().BeTrue();
item.CanMoveFiles.Should().BeTrue();
} }
[Test] [Test]

View file

@ -1,4 +1,4 @@
using System; using System;
using System.Linq; using System.Linq;
using System.Collections.Generic; using System.Collections.Generic;
using FluentAssertions; using FluentAssertions;
@ -139,6 +139,9 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.NzbVortexTests
var result = Subject.GetItems().Single(); var result = Subject.GetItems().Single();
VerifyCompleted(result); VerifyCompleted(result);
result.CanBeRemoved.Should().BeTrue();
result.CanMoveFiles.Should().BeTrue();
} }
[Test] [Test]

View file

@ -1,4 +1,4 @@
using System; using System;
using System.Linq; using System.Linq;
using System.Collections.Generic; using System.Collections.Generic;
using FluentAssertions; using FluentAssertions;
@ -204,6 +204,9 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.NzbgetTests
var result = Subject.GetItems().Single(); var result = Subject.GetItems().Single();
VerifyCompleted(result); VerifyCompleted(result);
result.CanBeRemoved.Should().BeTrue();
result.CanMoveFiles.Should().BeTrue();
} }
[Test] [Test]

View file

@ -1,4 +1,4 @@
using System; using System;
using System.Linq; using System.Linq;
using System.Collections.Generic; using System.Collections.Generic;
using FluentAssertions; using FluentAssertions;
@ -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]

View file

@ -1,4 +1,4 @@
using System; using System;
using System.Linq; using System.Linq;
using System.Collections.Generic; using System.Collections.Generic;
using FizzWare.NBuilder; using FizzWare.NBuilder;
@ -239,6 +239,9 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.SabnzbdTests
var result = Subject.GetItems().Single(); var result = Subject.GetItems().Single();
VerifyCompleted(result); VerifyCompleted(result);
result.CanBeRemoved.Should().BeTrue();
result.CanMoveFiles.Should().BeTrue();
} }
[Test] [Test]

View file

@ -1,4 +1,4 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using FluentAssertions; using FluentAssertions;
using Moq; using Moq;
@ -41,6 +41,9 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.TransmissionTests
PrepareClientToReturnCompletedItem(); PrepareClientToReturnCompletedItem();
var item = Subject.GetItems().Single(); var item = Subject.GetItems().Single();
VerifyCompleted(item); VerifyCompleted(item);
item.CanBeRemoved.Should().BeTrue();
item.CanMoveFiles.Should().BeTrue();
} }
[Test] [Test]
@ -172,13 +175,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 +190,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]

View file

@ -1,4 +1,4 @@
using System; using System;
using System.Linq; using System.Linq;
using System.Collections.Generic; using System.Collections.Generic;
using FluentAssertions; using FluentAssertions;
@ -222,6 +222,9 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.UTorrentTests
PrepareClientToReturnCompletedItem(); PrepareClientToReturnCompletedItem();
var item = Subject.GetItems().Single(); var item = Subject.GetItems().Single();
VerifyCompleted(item); VerifyCompleted(item);
item.CanBeRemoved.Should().BeTrue();
item.CanMoveFiles.Should().BeTrue();
} }
[Test] [Test]
@ -292,12 +295,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 +309,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]

View file

@ -1,4 +1,4 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using FluentAssertions; using FluentAssertions;
using Moq; using Moq;
@ -43,6 +43,9 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.VuzeTests
PrepareClientToReturnCompletedItem(); PrepareClientToReturnCompletedItem();
var item = Subject.GetItems().Single(); var item = Subject.GetItems().Single();
VerifyCompleted(item); VerifyCompleted(item);
item.CanBeRemoved.Should().BeTrue();
item.CanMoveFiles.Should().BeTrue();
} }
[Test] [Test]
@ -174,13 +177,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 +192,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]

View file

@ -67,7 +67,7 @@ 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))));

View file

@ -1,5 +1,6 @@
using System; using System;
using System.Linq; using System.Linq;
using System.Net;
using FluentAssertions; using FluentAssertions;
using Moq; using Moq;
using NUnit.Framework; using NUnit.Framework;
@ -7,6 +8,7 @@ using NzbDrone.Common.Http;
using NzbDrone.Core.Indexers; using NzbDrone.Core.Indexers;
using NzbDrone.Core.Indexers.Newznab; using NzbDrone.Core.Indexers.Newznab;
using NzbDrone.Core.Test.Framework; using NzbDrone.Core.Test.Framework;
using NzbDrone.Test.Common;
namespace NzbDrone.Core.Test.IndexerTests.NewznabTests namespace NzbDrone.Core.Test.IndexerTests.NewznabTests
{ {
@ -69,5 +71,27 @@ namespace NzbDrone.Core.Test.IndexerTests.NewznabTests
Subject.PageSize.Should().Be(25); Subject.PageSize.Should().Be(25);
} }
}
[Test]
public void should_record_indexer_failure_if_caps_throw()
{
var request = new HttpRequest("http://my.indexer.com");
var response = new HttpResponse(request, new HttpHeader(), new byte[0], (HttpStatusCode)429);
response.Headers["Retry-After"] = "300";
Mocker.GetMock<INewznabCapabilitiesProvider>()
.Setup(v => v.GetCapabilities(It.IsAny<NewznabSettings>()))
.Throws(new TooManyRequestsException(request, response));
_caps.MaxPageSize = 30;
_caps.DefaultPageSize = 25;
Subject.FetchRecent().Should().BeEmpty();
Mocker.GetMock<IIndexerStatusService>()
.Verify(v => v.RecordFailure(It.IsAny<int>(), TimeSpan.FromMinutes(5.0)), Times.Once());
ExceptionVerification.ExpectedWarns(1);
}
}
} }

View file

@ -231,9 +231,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.UpgradeTrackFile(It.IsAny<TrackFile>(), _approvedDecisions.First().LocalTrack, true), Times.Once()); .Verify(v => v.UpgradeTrackFile(It.IsAny<TrackFile>(), _approvedDecisions.First().LocalTrack, true), Times.Once());
@ -242,7 +242,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.UpgradeTrackFile(It.IsAny<TrackFile>(), _approvedDecisions.First().LocalTrack, false), Times.Once()); .Verify(v => v.UpgradeTrackFile(It.IsAny<TrackFile>(), _approvedDecisions.First().LocalTrack, false), Times.Once());

View file

@ -1,4 +1,5 @@
using System.Linq; using System.IO;
using System.Linq;
using FizzWare.NBuilder; using FizzWare.NBuilder;
using FluentAssertions; using FluentAssertions;
using Marr.Data; using Marr.Data;
@ -36,6 +37,10 @@ namespace NzbDrone.Core.Test.MediaFiles
Mocker.GetMock<IDiskProvider>() Mocker.GetMock<IDiskProvider>()
.Setup(c => c.FileExists(It.IsAny<string>())) .Setup(c => c.FileExists(It.IsAny<string>()))
.Returns(true); .Returns(true);
Mocker.GetMock<IDiskProvider>()
.Setup(c => c.GetParentFolder(It.IsAny<string>()))
.Returns<string>(c => Path.GetDirectoryName(c));
} }
private void GivenSingleTrackWithSingleTrackFile() private void GivenSingleTrackWithSingleTrackFile()

View file

@ -127,6 +127,7 @@ namespace NzbDrone.Core.Test.ParserTests
[TestCase("this.is.not.happening.2015.0308-yestv", "this is not happening 2015", 3, 8)] [TestCase("this.is.not.happening.2015.0308-yestv", "this is not happening 2015", 3, 8)]
[TestCase("Jeopardy - S2016E231", "Jeopardy", 2016, 231)] [TestCase("Jeopardy - S2016E231", "Jeopardy", 2016, 231)]
[TestCase("Jeopardy - 2016x231", "Jeopardy", 2016, 231)] [TestCase("Jeopardy - 2016x231", "Jeopardy", 2016, 231)]
[TestCase("Shortland.Street.S26E022.HDTV.x264-FiHTV", "Shortland Street", 26, 22)]
//[TestCase("", "", 0, 0)] //[TestCase("", "", 0, 0)]
public void should_parse_single_episode(string postTitle, string title, int seasonNumber, int episodeNumber) public void should_parse_single_episode(string postTitle, string title, int seasonNumber, int episodeNumber)
{ {

View file

@ -1,4 +1,4 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Text; using System.Text;
@ -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
}; };
} }
} }

View file

@ -1,4 +1,4 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using FluentValidation.Results; using FluentValidation.Results;
@ -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
}; };
} }
} }

View file

@ -1,4 +1,4 @@
using System; using System;
using System.Linq; using System.Linq;
using System.Collections.Generic; using System.Collections.Generic;
using NzbDrone.Common.Disk; using NzbDrone.Common.Disk;
@ -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);
} }

View file

@ -1,4 +1,4 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
@ -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,7 +200,12 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation
return torrent.Status == DownloadStationTaskStatus.Finished; return torrent.Status == DownloadStationTaskStatus.Finished;
} }
protected string GetMessage(DownloadStationTask torrent) 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) if (torrent.StatusExtra != null)
{ {

View file

@ -1,4 +1,4 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Net; using System.Net;
@ -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)

View file

@ -1,4 +1,4 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using FluentValidation.Results; using FluentValidation.Results;
@ -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);
} }

View file

@ -1,4 +1,4 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
@ -73,6 +73,9 @@ namespace NzbDrone.Core.Download.Clients.NzbVortex
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;

View file

@ -1,4 +1,4 @@
using System; using System;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Collections.Generic; using System.Collections.Generic;
@ -145,6 +145,8 @@ namespace NzbDrone.Core.Download.Clients.Nzbget
historyItem.Message = $"PAR Status: {item.ParStatus} - Unpack Status: {item.UnpackStatus} - Move Status: {item.MoveStatus} - Script Status: {item.ScriptStatus} - Delete Status: {item.DeleteStatus} - Mark Status: {item.MarkStatus}"; historyItem.Message = $"PAR Status: {item.ParStatus} - Unpack Status: {item.UnpackStatus} - Move Status: {item.MoveStatus} - Script Status: {item.ScriptStatus} - Delete Status: {item.DeleteStatus} - Mark Status: {item.MarkStatus}";
historyItem.Status = DownloadItemStatus.Completed; historyItem.Status = DownloadItemStatus.Completed;
historyItem.RemainingTime = TimeSpan.Zero; historyItem.RemainingTime = TimeSpan.Zero;
historyItem.CanMoveFiles = true;
historyItem.CanBeRemoved = true;
if (item.DeleteStatus == "MANUAL") if (item.DeleteStatus == "MANUAL")
{ {

View file

@ -72,6 +72,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)

View file

@ -1,4 +1,4 @@
using System; using System;
using System.Linq; using System.Linq;
using System.Collections.Generic; using System.Collections.Generic;
using NzbDrone.Common.Disk; using NzbDrone.Common.Disk;
@ -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)
{ {

View file

@ -1,4 +1,4 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
@ -160,6 +160,8 @@ namespace NzbDrone.Core.Download.Clients.Sabnzbd
else if (sabHistoryItem.Status == SabnzbdDownloadStatus.Completed) else if (sabHistoryItem.Status == SabnzbdDownloadStatus.Completed)
{ {
historyItem.Status = DownloadItemStatus.Completed; historyItem.Status = DownloadItemStatus.Completed;
historyItem.CanBeRemoved = true;
historyItem.CanMoveFiles = true;
} }
else // Verifying/Moving etc else // Verifying/Moving etc
{ {

View file

@ -1,4 +1,4 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Net; using System.Net;
@ -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);
} }

View file

@ -1,4 +1,4 @@
using System; using System;
using System.Linq; using System.Linq;
using System.Collections.Generic; using System.Collections.Generic;
using System.Threading; using System.Threading;
@ -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);
} }

View file

@ -1,4 +1,4 @@
using System; using System;
using System.Linq; using System.Linq;
using System.Collections.Generic; using System.Collections.Generic;
using NzbDrone.Common.Disk; using NzbDrone.Common.Disk;
@ -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);
} }

View file

@ -25,8 +25,6 @@ namespace NzbDrone.Core.Download
public bool CanMoveFiles { get; set; } public bool CanMoveFiles { get; set; }
public bool CanBeRemoved { get; set; } public bool CanBeRemoved { get; set; }
public bool IsReadOnly { get; set; }
public bool Removed { get; set; } public bool Removed { get; set; }
} }
} }

View file

@ -1,4 +1,4 @@
using System; using System;
using NLog; using NLog;
using NzbDrone.Common.Messaging; using NzbDrone.Common.Messaging;
using NzbDrone.Core.Configuration; using NzbDrone.Core.Configuration;
@ -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;
} }

View file

@ -109,7 +109,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));
} }

View file

@ -46,9 +46,7 @@ namespace NzbDrone.Core.Indexers
return new List<ReleaseInfo>(); return new List<ReleaseInfo>();
} }
var generator = GetRequestGenerator(); return FetchReleases(g => g.GetRecentRequests(), true);
return FetchReleases(generator.GetRecentRequests(), true);
} }
public override IList<ReleaseInfo> Fetch(AlbumSearchCriteria searchCriteria) public override IList<ReleaseInfo> Fetch(AlbumSearchCriteria searchCriteria)
@ -58,9 +56,7 @@ namespace NzbDrone.Core.Indexers
return new List<ReleaseInfo>(); return new List<ReleaseInfo>();
} }
var generator = GetRequestGenerator(); return FetchReleases(g => g.GetSearchRequests(searchCriteria));
return FetchReleases(generator.GetSearchRequests(searchCriteria));
} }
public override IList<ReleaseInfo> Fetch(ArtistSearchCriteria searchCriteria) public override IList<ReleaseInfo> Fetch(ArtistSearchCriteria searchCriteria)
@ -70,20 +66,22 @@ namespace NzbDrone.Core.Indexers
return new List<ReleaseInfo>(); return new List<ReleaseInfo>();
} }
var generator = GetRequestGenerator(); return FetchReleases(g => g.GetSearchRequests(searchCriteria));
return FetchReleases(generator.GetSearchRequests(searchCriteria));
} }
protected virtual IList<ReleaseInfo> FetchReleases(IndexerPageableRequestChain pageableRequestChain, bool isRecent = false) protected virtual IList<ReleaseInfo> FetchReleases(Func<IIndexerRequestGenerator, IndexerPageableRequestChain> pageableRequestChainSelector, bool isRecent = false)
{ {
var releases = new List<ReleaseInfo>(); var releases = new List<ReleaseInfo>();
var url = string.Empty; var url = string.Empty;
var parser = GetParser();
try try
{ {
var generator = GetRequestGenerator();
var parser = GetParser();
var pageableRequestChain = pageableRequestChainSelector(generator);
var fullyUpdated = false; var fullyUpdated = false;
ReleaseInfo lastReleaseInfo = null; ReleaseInfo lastReleaseInfo = null;
if (isRecent) if (isRecent)
@ -186,18 +184,22 @@ namespace NzbDrone.Core.Indexers
_logger.Warn("{0} {1} {2}", this, url, webException.Message); _logger.Warn("{0} {1} {2}", this, url, webException.Message);
} }
} }
catch (HttpException httpException) catch (TooManyRequestsException ex)
{ {
if ((int)httpException.Response.StatusCode == 429) if (ex.RetryAfter != TimeSpan.Zero)
{ {
_indexerStatusService.RecordFailure(Definition.Id, TimeSpan.FromHours(1)); _indexerStatusService.RecordFailure(Definition.Id, ex.RetryAfter);
_logger.Warn("API Request Limit reached for {0}", this);
} }
else else
{ {
_indexerStatusService.RecordFailure(Definition.Id); _indexerStatusService.RecordFailure(Definition.Id, TimeSpan.FromHours(1));
_logger.Warn("{0} {1}", this, httpException.Message);
} }
_logger.Warn("API Request Limit reached for {0}", this);
}
catch (HttpException ex)
{
_indexerStatusService.RecordFailure(Definition.Id);
_logger.Warn("{0} {1}", this, ex.Message);
} }
catch (RequestLimitReachedException) catch (RequestLimitReachedException)
{ {

View file

@ -199,7 +199,7 @@ namespace NzbDrone.Core.MediaFiles
var decisions = _importDecisionMaker.GetImportDecisions(audioFiles.ToList(), artist, trackInfo); var decisions = _importDecisionMaker.GetImportDecisions(audioFiles.ToList(), artist, trackInfo);
var importResults = _importApprovedTracks.Import(decisions, true, downloadClientItem, importMode); var importResults = _importApprovedTracks.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, artist)) ShouldDeleteFolder(directoryInfo, artist))
{ {

View file

@ -1,4 +1,4 @@
using NzbDrone.Common.Messaging; using NzbDrone.Common.Messaging;
using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Parser.Model;
namespace NzbDrone.Core.MediaFiles.Events namespace NzbDrone.Core.MediaFiles.Events
@ -10,7 +10,6 @@ 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 EpisodeImportedEvent(LocalEpisode episodeInfo, EpisodeFile importedEpisode, bool newDownload) public EpisodeImportedEvent(LocalEpisode episodeInfo, EpisodeFile importedEpisode, bool newDownload)
{ {
@ -19,14 +18,13 @@ 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)
{ {
EpisodeInfo = episodeInfo; EpisodeInfo = episodeInfo;
ImportedEpisode = importedEpisode; ImportedEpisode = importedEpisode;
NewDownload = newDownload; NewDownload = newDownload;
DownloadClient = downloadClient; DownloadClient = downloadClient;
DownloadId = downloadId; DownloadId = downloadId;
IsReadOnly = isReadOnly;
} }
} }
} }

View file

@ -1,4 +1,4 @@
using NzbDrone.Common.Messaging; using NzbDrone.Common.Messaging;
using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Parser.Model;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@ -14,7 +14,6 @@ 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 TrackImportedEvent(LocalTrack trackInfo, TrackFile importedTrack, bool newDownload) public TrackImportedEvent(LocalTrack trackInfo, TrackFile importedTrack, bool newDownload)
{ {
@ -23,14 +22,13 @@ namespace NzbDrone.Core.MediaFiles.Events
NewDownload = newDownload; NewDownload = newDownload;
} }
public TrackImportedEvent(LocalTrack trackInfo, TrackFile importedTrack, bool newDownload, string downloadClient, string downloadId, bool isReadOnly) public TrackImportedEvent(LocalTrack trackInfo, TrackFile importedTrack, bool newDownload, string downloadClient, string downloadId)
{ {
TrackInfo = trackInfo; TrackInfo = trackInfo;
ImportedTrack = importedTrack; ImportedTrack = importedTrack;
NewDownload = newDownload; NewDownload = newDownload;
DownloadClient = downloadClient; DownloadClient = downloadClient;
DownloadId = downloadId; DownloadId = downloadId;
IsReadOnly = isReadOnly;
} }
} }
} }

View file

@ -94,7 +94,7 @@ namespace NzbDrone.Core.MediaFiles.TrackImport
{ {
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;
@ -126,7 +126,7 @@ namespace NzbDrone.Core.MediaFiles.TrackImport
if (downloadClientItem != null) if (downloadClientItem != null)
{ {
_eventAggregator.PublishEvent(new TrackImportedEvent(localTrack, trackFile, newDownload, downloadClientItem.DownloadClient, downloadClientItem.DownloadId, downloadClientItem.IsReadOnly)); _eventAggregator.PublishEvent(new TrackImportedEvent(localTrack, trackFile, newDownload, downloadClientItem.DownloadClient, downloadClientItem.DownloadId));
} }
else else
{ {

View file

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