From 56a07709f6c2ac7f369b3dfa567b52a3026836c0 Mon Sep 17 00:00:00 2001 From: Ben Sarmiento Date: Sun, 7 Jan 2024 15:14:23 +0100 Subject: [PATCH] Send to unplayable directory --- internal/torrent/refresh.go | 3 --- internal/torrent/repair.go | 9 +++++++++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/internal/torrent/refresh.go b/internal/torrent/refresh.go index 7140811..bd5d663 100644 --- a/internal/torrent/refresh.go +++ b/internal/torrent/refresh.go @@ -64,9 +64,6 @@ func (t *TorrentManager) RefreshTorrents() []string { } var directories []string t.assignedDirectoryCb(tor, func(directory string) { - if strings.HasPrefix(directory, "int__") { - return - } torrents, _ := t.DirectoryMap.Get(directory) torrents.Set(accessKey, tor) updatedPaths = append(updatedPaths, fmt.Sprintf("%s/%s", directory, accessKey)) diff --git a/internal/torrent/repair.go b/internal/torrent/repair.go index 4f2e260..b8affe0 100644 --- a/internal/torrent/repair.go +++ b/internal/torrent/repair.go @@ -6,7 +6,9 @@ import ( "strings" "time" + "github.com/debridmediamanager/zurg/internal/config" "github.com/debridmediamanager/zurg/pkg/realdebrid" + cmap "github.com/orcaman/concurrent-map/v2" ) const EXPIRED_LINK_TOLERANCE_HOURS = 24 @@ -115,7 +117,9 @@ func (t *TorrentManager) repair(torrent *Torrent) { if assignedCount > 0 { t.log.Infof("Assigned %d links to selected files for torrent %s", assignedCount, torrent.AccessKey) } else if rarCount > 0 { + // this is a rar'ed torrent, nothing we can do if t.Config.ShouldDeleteRarFiles() { + t.log.Warnf("Torrent %s is rar'ed and we cannot repair it, deleting it as configured", torrent.AccessKey) t.Delete(torrent.AccessKey, true) } else { for _, unassigned := range unassignedDownloads { @@ -131,6 +135,11 @@ func (t *TorrentManager) repair(torrent *Torrent) { } torrent.SelectedFiles.Set(unassigned.Filename, newFile) } + t.DirectoryMap.IterCb(func(directory string, torrents cmap.ConcurrentMap[string, *Torrent]) { + torrents.Remove(torrent.AccessKey) + }) + torrents, _ := t.DirectoryMap.Get(config.UNPLAYABLE_TORRENTS) + torrents.Set(torrent.AccessKey, torrent) } return }