diff --git a/server/RdtClient.Service/Services/DebridClients/TorBoxDebridClient.cs b/server/RdtClient.Service/Services/DebridClients/TorBoxDebridClient.cs index 98b9b175..109a6df5 100644 --- a/server/RdtClient.Service/Services/DebridClients/TorBoxDebridClient.cs +++ b/server/RdtClient.Service/Services/DebridClients/TorBoxDebridClient.cs @@ -144,6 +144,11 @@ public async Task> GetAvailableFiles(String has /// public Task SelectFiles(Torrent torrent) { + if (torrent.Files.Count == 0) + { + return Task.FromResult(null); + } + return Task.FromResult(torrent.Files.Count); } diff --git a/server/RdtClient.Service/Services/TorrentRunner.cs b/server/RdtClient.Service/Services/TorrentRunner.cs index 5739104d..989513c6 100644 --- a/server/RdtClient.Service/Services/TorrentRunner.cs +++ b/server/RdtClient.Service/Services/TorrentRunner.cs @@ -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. diff --git a/server/RdtClient.Service/Services/Torrents.cs b/server/RdtClient.Service/Services/Torrents.cs index bdd34b8e..4cfcc606 100644 --- a/server/RdtClient.Service/Services/Torrents.cs +++ b/server/RdtClient.Service/Services/Torrents.cs @@ -415,21 +415,30 @@ public async Task> GetAvailableFiles(String has return result; } - public async Task SelectFiles(Guid torrentId) + public async Task 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)