From 03a1d738259d3c95d15bcc781160a238f3d6661d Mon Sep 17 00:00:00 2001 From: Mukhtar Akere Date: Tue, 13 May 2025 14:00:03 +0100 Subject: [PATCH] Fix issues with __bad__ --- pkg/debrid/debrid/cache.go | 4 +--- pkg/debrid/debrid/repair.go | 6 +++--- pkg/debrid/debrid/torrent.go | 1 + pkg/webdav/handler.go | 2 +- 4 files changed, 6 insertions(+), 7 deletions(-) diff --git a/pkg/debrid/debrid/cache.go b/pkg/debrid/debrid/cache.go index d15343a..e50243a 100644 --- a/pkg/debrid/debrid/cache.go +++ b/pkg/debrid/debrid/cache.go @@ -49,6 +49,7 @@ func (c CachedTorrent) copy() CachedTorrent { Torrent: c.Torrent, AddedOn: c.AddedOn, IsComplete: c.IsComplete, + Bad: c.Bad, } } @@ -308,9 +309,6 @@ func (c *Cache) Sync() error { newTorrents := make([]*types.Torrent, 0) idStore := make(map[string]struct{}, totalTorrents) for _, t := range torrents { - if _, exists := idStore[t.Id]; exists { - c.logger.Debug().Msgf("Torrent %s already exists in cache", t.Id) - } idStore[t.Id] = struct{}{} if _, ok := cachedTorrents[t.Id]; !ok { newTorrents = append(newTorrents, t) diff --git a/pkg/debrid/debrid/repair.go b/pkg/debrid/debrid/repair.go index aa8ce11..80a8b05 100644 --- a/pkg/debrid/debrid/repair.go +++ b/pkg/debrid/debrid/repair.go @@ -39,8 +39,8 @@ func (c *Cache) markAsFailedToReinsert(torrentId string) { // Remove the torrent from the directory if it has failed to reinsert, max retries are hardcoded to 5 if torrent, ok := c.torrents.getByID(torrentId); ok { torrent.Bad = true - c.setTorrent(torrent, func(torrent CachedTorrent) { - c.listingDebouncer.Call(false) + c.setTorrent(torrent, func(t CachedTorrent) { + c.RefreshListings(false) }) } } @@ -53,7 +53,7 @@ func (c *Cache) markAsSuccessfullyReinserted(torrentId string) { if torrent, ok := c.torrents.getByID(torrentId); ok { torrent.Bad = false c.setTorrent(torrent, func(torrent CachedTorrent) { - c.listingDebouncer.Call(false) + c.RefreshListings(false) }) } } diff --git a/pkg/debrid/debrid/torrent.go b/pkg/debrid/debrid/torrent.go index 4d48351..1d42fab 100644 --- a/pkg/debrid/debrid/torrent.go +++ b/pkg/debrid/debrid/torrent.go @@ -182,6 +182,7 @@ func (tc *torrentCache) refreshListing() { } tc.folderListingMu.Unlock() }() + wg.Done() now := time.Now() wg.Add(len(tc.directoriesFilters)) // for each directory filter diff --git a/pkg/webdav/handler.go b/pkg/webdav/handler.go index e232283..502bde5 100644 --- a/pkg/webdav/handler.go +++ b/pkg/webdav/handler.go @@ -269,7 +269,7 @@ func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) { LockSystem: webdav.NewMemLS(), Logger: func(r *http.Request, err error) { if err != nil { - h.logger.Error(). + h.logger.Trace(). Err(err). Str("method", r.Method). Str("path", r.URL.Path).