From 52046cb3dbce7fe4ed4f343efe2f51c6545e39d9 Mon Sep 17 00:00:00 2001 From: Ben Sarmiento Date: Fri, 26 Jan 2024 22:51:08 +0100 Subject: [PATCH] Rigorous fix check --- internal/torrent/refresh.go | 1 + internal/torrent/repair.go | 7 +++++-- internal/torrent/uncached.go | 4 ++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/internal/torrent/refresh.go b/internal/torrent/refresh.go index a3d98ce..cf8d247 100644 --- a/internal/torrent/refresh.go +++ b/internal/torrent/refresh.go @@ -63,6 +63,7 @@ func (t *TorrentManager) RefreshTorrents() []string { t.log.Debugf("Ensuring that torrent id=%s is deleted", fixerID) t.Delete(t.GetKey(torrent), true) t.Api.DeleteTorrent(fixerID) + infoCache.Remove(fixerID) return false }) diff --git a/internal/torrent/repair.go b/internal/torrent/repair.go index 0e142cc..8c1d2a5 100644 --- a/internal/torrent/repair.go +++ b/internal/torrent/repair.go @@ -31,7 +31,7 @@ func (t *TorrentManager) repairAll() { toRepair := mapset.NewSet[*Torrent]() allTorrents.IterCb(func(_ string, torrent *Torrent) { - if torrent.AnyInProgress() || torrent.UnrepairableReason != "" { + if torrent.AnyInProgress() || torrent.AllInProgress() || torrent.UnrepairableReason != "" { return } @@ -102,7 +102,7 @@ func (t *TorrentManager) Repair(torrent *Torrent) { t.log.Warnf("Torrent %s is already being repaired, skipping repair", t.GetKey(torrent)) return } - if torrent.AnyInProgress() { + if torrent.AnyInProgress() || torrent.AllInProgress() { t.log.Infof("Torrent %s is in progress, skipping repair until download is done", t.GetKey(torrent)) return } @@ -344,9 +344,12 @@ func (t *TorrentManager) redownloadTorrent(torrent *Torrent, selection string) ( if len(oldTorrentIDs) > 0 { // replace the old torrent + infoCache, _ := t.DirectoryMap.Get(INT_INFO_CACHE) for _, id := range oldTorrentIDs { + torrent.DownloadedIDs.Remove(id) t.Api.DeleteTorrent(id) t.deleteOnceDone.Add(id) + infoCache.Remove(id) } } else { // it's a fixer diff --git a/internal/torrent/uncached.go b/internal/torrent/uncached.go index f3097a8..9bcf5fb 100644 --- a/internal/torrent/uncached.go +++ b/internal/torrent/uncached.go @@ -17,7 +17,7 @@ func (t *TorrentManager) getUncachedTorrents() ([]*Torrent, error) { hashGroups = append(hashGroups, currentGroup) allTorrents.IterCb(func(_ string, torrent *Torrent) { - if torrent.AnyInProgress() || torrent.UnrepairableReason != "" { + if torrent.AnyInProgress() || torrent.AllInProgress() || torrent.UnrepairableReason != "" { return } @@ -46,7 +46,7 @@ func (t *TorrentManager) getUncachedTorrents() ([]*Torrent, error) { var uncachedTorrents []*Torrent allTorrents.IterCb(func(_ string, torrent *Torrent) { - if torrent.AnyInProgress() || torrent.UnrepairableReason != "" { + if torrent.AnyInProgress() || torrent.AllInProgress() || torrent.UnrepairableReason != "" { return }