[AD] mark torrent failed when all files excluded by filters
This commit is contained in:
parent
a366328472
commit
097ea93410
2 changed files with 5 additions and 21 deletions
|
|
@ -476,7 +476,7 @@ public class AllDebridTorrentClientTest
|
|||
}
|
||||
|
||||
[Fact]
|
||||
public async Task GetDownloadLinks_WhenAllFilesExcluded_ReturnsAllFiles()
|
||||
public async Task GetDownloadLinks_WhenAllFilesExcluded_ReturnsEmptyList()
|
||||
{
|
||||
// Arrange
|
||||
var mocks = new Mocks();
|
||||
|
|
@ -501,8 +501,7 @@ public class AllDebridTorrentClientTest
|
|||
DownloadLink = "https://fake.url/file-2.txt"
|
||||
}
|
||||
];
|
||||
|
||||
var expectedLinksSet = new HashSet<String>(files.Select(n => n.DownloadLink)!);
|
||||
|
||||
mocks.AllDebridClientMock.Setup(c => c.Magnet.FilesAsync(Int64.Parse(torrent.RdId), It.IsAny<CancellationToken>())).ReturnsAsync(files);
|
||||
mocks.FileFilterMock.Setup(f => f.IsDownloadable(torrent, It.IsAny<String>(), It.IsAny<Int64>())).Returns(false);
|
||||
|
||||
|
|
@ -513,8 +512,7 @@ public class AllDebridTorrentClientTest
|
|||
|
||||
// Assert
|
||||
Assert.NotNull(result);
|
||||
var linksSet = new HashSet<String>(result);
|
||||
Assert.Equal(expectedLinksSet, linksSet);
|
||||
Assert.Empty(result);
|
||||
|
||||
mocks.FileFilterMock.Verify(f => f.IsDownloadable(torrent, "file-1.txt", 100));
|
||||
mocks.FileFilterMock.Verify(f => f.IsDownloadable(torrent, "file-2.txt", 100));
|
||||
|
|
|
|||
|
|
@ -252,28 +252,14 @@ public class AllDebridTorrentClient(ILogger<AllDebridTorrentClient> logger, IAll
|
|||
return null;
|
||||
}
|
||||
|
||||
Log($"Getting download links", torrent);
|
||||
|
||||
var allFiles = await allDebridNetClientFactory.GetClient().Magnet.FilesAsync(Int64.Parse(torrent.RdId));
|
||||
|
||||
var files = GetFiles(allFiles);
|
||||
|
||||
files = files.Where(f => fileFilter.IsDownloadable(torrent, f.Path, f.Bytes)).ToList();
|
||||
|
||||
Log($"Getting download links", torrent);
|
||||
|
||||
if (files.Count == 0)
|
||||
{
|
||||
Log($"Filtered all files out! Downloading ALL files instead!", torrent);
|
||||
|
||||
files = GetFiles(allFiles);
|
||||
}
|
||||
|
||||
Log($"Selecting links:");
|
||||
|
||||
foreach (var file in files)
|
||||
{
|
||||
Log($"{file.Path} ({file.Bytes}b) {file.DownloadLink}");
|
||||
}
|
||||
|
||||
return files.Where(m => m.DownloadLink != null).Select(m => m.DownloadLink!.ToString()).ToList();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue