Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,11 @@ public async Task<IList<DebridClientAvailableFile>> GetAvailableFiles(String has
/// <inheritdoc />
public Task<Int32?> SelectFiles(Torrent torrent)
{
if (torrent.Files.Count == 0)
{
return Task.FromResult<Int32?>(null);
}

return Task.FromResult<Int32?>(torrent.Files.Count);
}

Expand Down
7 changes: 5 additions & 2 deletions server/RdtClient.Service/Services/TorrentRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -710,9 +710,12 @@ await remoteService.UpdateRateLimitStatus(new()
{
Log($"Selecting files", torrent);

await torrents.SelectFiles(torrent.TorrentId);
var filesSelected = await torrents.SelectFiles(torrent.TorrentId);

await torrents.UpdateFilesSelected(torrent.TorrentId, DateTime.UtcNow);
if (filesSelected)
{
await torrents.UpdateFilesSelected(torrent.TorrentId, DateTime.UtcNow);
}
}

// Debrid provider finished downloading the torrent, process the file to host.
Expand Down
13 changes: 11 additions & 2 deletions server/RdtClient.Service/Services/Torrents.cs
Original file line number Diff line number Diff line change
Expand Up @@ -415,21 +415,30 @@ public async Task<IList<DebridClientAvailableFile>> GetAvailableFiles(String has
return result;
}

public async Task SelectFiles(Guid torrentId)
public async Task<Boolean> SelectFiles(Guid torrentId)
{
var torrent = await GetById(torrentId);

if (torrent == null)
{
return;
return true;
}

var selected = await DebridClient.SelectFiles(torrent);

if (selected == null)
{
logger.LogWarning("File list not yet available from the debrid provider, retrying file selection next cycle {torrentInfo}", torrent.ToLog());

return false;
}

if (selected == 0)
{
await MarkAllFilesExcluded(torrent);
}

return true;
}

public async Task CreateDownloads(Guid torrentId)
Expand Down