[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]
|
[Fact]
|
||||||
public async Task GetDownloadLinks_WhenAllFilesExcluded_ReturnsAllFiles()
|
public async Task GetDownloadLinks_WhenAllFilesExcluded_ReturnsEmptyList()
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
var mocks = new Mocks();
|
var mocks = new Mocks();
|
||||||
|
|
@ -502,7 +502,6 @@ public class AllDebridTorrentClientTest
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
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.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);
|
mocks.FileFilterMock.Setup(f => f.IsDownloadable(torrent, It.IsAny<String>(), It.IsAny<Int64>())).Returns(false);
|
||||||
|
|
||||||
|
|
@ -513,8 +512,7 @@ public class AllDebridTorrentClientTest
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.NotNull(result);
|
Assert.NotNull(result);
|
||||||
var linksSet = new HashSet<String>(result);
|
Assert.Empty(result);
|
||||||
Assert.Equal(expectedLinksSet, linksSet);
|
|
||||||
|
|
||||||
mocks.FileFilterMock.Verify(f => f.IsDownloadable(torrent, "file-1.txt", 100));
|
mocks.FileFilterMock.Verify(f => f.IsDownloadable(torrent, "file-1.txt", 100));
|
||||||
mocks.FileFilterMock.Verify(f => f.IsDownloadable(torrent, "file-2.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;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Log($"Getting download links", torrent);
|
||||||
|
|
||||||
var allFiles = await allDebridNetClientFactory.GetClient().Magnet.FilesAsync(Int64.Parse(torrent.RdId));
|
var allFiles = await allDebridNetClientFactory.GetClient().Magnet.FilesAsync(Int64.Parse(torrent.RdId));
|
||||||
|
|
||||||
var files = GetFiles(allFiles);
|
var files = GetFiles(allFiles);
|
||||||
|
|
||||||
files = files.Where(f => fileFilter.IsDownloadable(torrent, f.Path, f.Bytes)).ToList();
|
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();
|
return files.Where(m => m.DownloadLink != null).Select(m => m.DownloadLink!.ToString()).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue