From c0703cb622813ea06edb5579b18bb8937b8f1b36 Mon Sep 17 00:00:00 2001 From: Mukhtar Akere Date: Tue, 29 Apr 2025 12:07:01 +0100 Subject: [PATCH] hotfix --- pkg/debrid/debrid/cache.go | 4 ++-- pkg/qbit/torrent.go | 3 ++- pkg/webdav/handler.go | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/pkg/debrid/debrid/cache.go b/pkg/debrid/debrid/cache.go index d7fa4d6..8536463 100644 --- a/pkg/debrid/debrid/cache.go +++ b/pkg/debrid/debrid/cache.go @@ -428,10 +428,10 @@ func (c *Cache) setTorrent(t *CachedTorrent) { // keep the one with the most recent added date // Save the most recent torrent + mergedFiles := mergeFiles(t, o) // Useful for merging files across multiple torrents, while keeping the most recent if o.AddedOn.After(t.AddedOn) { t = o } - mergedFiles := mergeFiles(t, o) // Useful for merging files across multiple torrents, while keeping the most recent t.Files = mergedFiles } @@ -445,10 +445,10 @@ func (c *Cache) setTorrents(torrents map[string]*CachedTorrent) { c.torrents.Store(t.Id, torrentKey) if o, ok := c.torrentsNames.Load(torrentKey); ok && o.Id != t.Id { // Save the most recent torrent + mergedFiles := mergeFiles(t, o) // Useful for merging files across multiple torrents, while keeping the most recent if o.AddedOn.After(t.AddedOn) { t = o } - mergedFiles := mergeFiles(t, o) t.Files = mergedFiles } c.torrentsNames.Store(torrentKey, t) diff --git a/pkg/qbit/torrent.go b/pkg/qbit/torrent.go index df19462..0767acf 100644 --- a/pkg/qbit/torrent.go +++ b/pkg/qbit/torrent.go @@ -109,12 +109,13 @@ func (q *QBit) ProcessFiles(torrent *Torrent, debridTorrent *debrid.Torrent, arr if ok { q.logger.Info().Msgf("Using internal webdav for %s", debridTorrent.Debrid) // Use webdav to download the file - timer := time.Now() + if err := cache.AddTorrent(debridTorrent); err != nil { q.logger.Error().Msgf("Error adding torrent to cache: %v", err) q.MarkAsFailed(torrent) return } + timer := time.Now() rclonePath := filepath.Join(debridTorrent.MountPath, cache.GetTorrentFolder(debridTorrent)) // /mnt/remote/realdebrid/MyTVShow torrentFolderNoExt := utils.RemoveExtension(debridTorrent.Name) diff --git a/pkg/webdav/handler.go b/pkg/webdav/handler.go index 5e2e3e3..c1492a9 100644 --- a/pkg/webdav/handler.go +++ b/pkg/webdav/handler.go @@ -349,7 +349,7 @@ func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) { Err(err). Str("path", r.URL.Path). Msg("Could not fetch download link") - http.Error(w, "Could not fetch download link", http.StatusServiceUnavailable) + http.Error(w, "Could not fetch download link", http.StatusPreconditionFailed) return } if link == "" {