Fix issues with __bad__

This commit is contained in:
Mukhtar Akere
2025-05-13 14:00:03 +01:00
parent 3b018b3571
commit 03a1d73825
4 changed files with 6 additions and 7 deletions

View File

@@ -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)

View File

@@ -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)
})
}
}

View File

@@ -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

View File

@@ -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).