mirror of
https://github.com/Sonarr/Sonarr.git
synced 2024-12-16 11:37:58 +02:00
Fixed: Remove on Activity page should now work for Blackhole items.
This commit is contained in:
parent
3dcfcbb400
commit
366f8c5239
@ -118,6 +118,58 @@ public void GetItems_should_considered_locked_files_queued()
|
||||
items.First().Status.Should().Be(DownloadItemStatus.Downloading);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void RemoveItem_should_delete_file()
|
||||
{
|
||||
GivenCompletedItem();
|
||||
|
||||
Mocker.GetMock<IDiskProvider>()
|
||||
.Setup(c => c.FileExists(It.IsAny<string>()))
|
||||
.Returns(true);
|
||||
|
||||
Subject.RemoveItem("_Droned.S01E01.Pilot.1080p.WEB-DL-DRONE_0", true);
|
||||
|
||||
Mocker.GetMock<IDiskProvider>()
|
||||
.Verify(c => c.DeleteFile(It.IsAny<string>()), Times.Once());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void RemoveItem_should_delete_directory()
|
||||
{
|
||||
GivenCompletedItem();
|
||||
|
||||
Subject.RemoveItem("_Droned.S01E01.Pilot.1080p.WEB-DL-DRONE_0", true);
|
||||
|
||||
Mocker.GetMock<IDiskProvider>()
|
||||
.Verify(c => c.DeleteFolder(It.IsAny<string>(), true), Times.Once());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void RemoveItem_should_throw_if_unknown_item()
|
||||
{
|
||||
Assert.Throws<ArgumentException>(() => Subject.RemoveItem("_Droned.S01E01.Pilot.1080p.WEB-DL-DRONE_0", true));
|
||||
|
||||
Mocker.GetMock<IDiskProvider>()
|
||||
.Verify(c => c.DeleteFile(It.IsAny<string>()), Times.Never());
|
||||
|
||||
Mocker.GetMock<IDiskProvider>()
|
||||
.Verify(c => c.DeleteFolder(It.IsAny<string>(), true), Times.Never());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void RemoveItem_should_throw_if_deleteData_is_false()
|
||||
{
|
||||
GivenCompletedItem();
|
||||
|
||||
Assert.Throws<NotSupportedException>(() => Subject.RemoveItem("_Droned.S01E01.Pilot.1080p.WEB-DL-DRONE_0", false));
|
||||
|
||||
Mocker.GetMock<IDiskProvider>()
|
||||
.Verify(c => c.DeleteFile(It.IsAny<string>()), Times.Never());
|
||||
|
||||
Mocker.GetMock<IDiskProvider>()
|
||||
.Verify(c => c.DeleteFolder(It.IsAny<string>(), true), Times.Never());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_status_with_outputdirs()
|
||||
{
|
||||
|
@ -1,3 +1,5 @@
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using System.Linq;
|
||||
@ -118,6 +120,58 @@ public void GetItems_should_considered_locked_files_downloading()
|
||||
result.Status.Should().Be(DownloadItemStatus.Downloading);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void RemoveItem_should_delete_file()
|
||||
{
|
||||
GivenCompletedItem();
|
||||
|
||||
Mocker.GetMock<IDiskProvider>()
|
||||
.Setup(c => c.FileExists(It.IsAny<string>()))
|
||||
.Returns(true);
|
||||
|
||||
Subject.RemoveItem("_Droned.S01E01.Pilot.1080p.WEB-DL-DRONE_0", true);
|
||||
|
||||
Mocker.GetMock<IDiskProvider>()
|
||||
.Verify(c => c.DeleteFile(It.IsAny<string>()), Times.Once());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void RemoveItem_should_delete_directory()
|
||||
{
|
||||
GivenCompletedItem();
|
||||
|
||||
Subject.RemoveItem("_Droned.S01E01.Pilot.1080p.WEB-DL-DRONE_0", true);
|
||||
|
||||
Mocker.GetMock<IDiskProvider>()
|
||||
.Verify(c => c.DeleteFolder(It.IsAny<string>(), true), Times.Once());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void RemoveItem_should_throw_if_unknown_item()
|
||||
{
|
||||
Assert.Throws<ArgumentException>(() => Subject.RemoveItem("_Droned.S01E01.Pilot.1080p.WEB-DL-DRONE_0", true));
|
||||
|
||||
Mocker.GetMock<IDiskProvider>()
|
||||
.Verify(c => c.DeleteFile(It.IsAny<string>()), Times.Never());
|
||||
|
||||
Mocker.GetMock<IDiskProvider>()
|
||||
.Verify(c => c.DeleteFolder(It.IsAny<string>(), true), Times.Never());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void RemoveItem_should_throw_if_deleteData_is_false()
|
||||
{
|
||||
GivenCompletedItem();
|
||||
|
||||
Assert.Throws<NotSupportedException>(() => Subject.RemoveItem("_Droned.S01E01.Pilot.1080p.WEB-DL-DRONE_0", false));
|
||||
|
||||
Mocker.GetMock<IDiskProvider>()
|
||||
.Verify(c => c.DeleteFile(It.IsAny<string>()), Times.Never());
|
||||
|
||||
Mocker.GetMock<IDiskProvider>()
|
||||
.Verify(c => c.DeleteFolder(It.IsAny<string>(), true), Times.Never());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_status_with_outputdirs()
|
||||
{
|
||||
|
@ -125,7 +125,28 @@ public override IEnumerable<DownloadClientItem> GetItems()
|
||||
|
||||
public override void RemoveItem(string downloadId, bool deleteData)
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
var downloadItem = GetItems().FirstOrDefault(v => v.DownloadId == downloadId);
|
||||
|
||||
if (downloadItem == null)
|
||||
{
|
||||
throw new ArgumentException(string.Format("Cannot remove DownloadItem {0} because it was not found.", downloadId));
|
||||
}
|
||||
|
||||
if (!deleteData)
|
||||
{
|
||||
throw new NotSupportedException("Blackhole cannot remove DownloadItem without deleting the data as well, ignoring.");
|
||||
}
|
||||
|
||||
var outputPath = downloadItem.OutputPath.FullPath;
|
||||
|
||||
if (_diskProvider.FileExists(outputPath))
|
||||
{
|
||||
_diskProvider.DeleteFile(outputPath);
|
||||
}
|
||||
else
|
||||
{
|
||||
_diskProvider.DeleteFolder(outputPath, true);
|
||||
}
|
||||
}
|
||||
|
||||
public override DownloadClientStatus GetStatus()
|
||||
|
@ -123,7 +123,28 @@ public override IEnumerable<DownloadClientItem> GetItems()
|
||||
|
||||
public override void RemoveItem(string downloadId, bool deleteData)
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
var downloadItem = GetItems().FirstOrDefault(v => v.DownloadId == downloadId);
|
||||
|
||||
if (downloadItem == null)
|
||||
{
|
||||
throw new ArgumentException(string.Format("Cannot remove DownloadItem {0} because it was not found.", downloadId));
|
||||
}
|
||||
|
||||
if (!deleteData)
|
||||
{
|
||||
throw new NotSupportedException("Blackhole cannot remove DownloadItem without deleting the data as well, ignoring.");
|
||||
}
|
||||
|
||||
var outputPath = downloadItem.OutputPath.FullPath;
|
||||
|
||||
if (_diskProvider.FileExists(outputPath))
|
||||
{
|
||||
_diskProvider.DeleteFile(outputPath);
|
||||
}
|
||||
else
|
||||
{
|
||||
_diskProvider.DeleteFolder(outputPath, true);
|
||||
}
|
||||
}
|
||||
|
||||
public override DownloadClientStatus GetStatus()
|
||||
|
Loading…
Reference in New Issue
Block a user