From 4c23402c2618bbb3db02daa8f850cefdb27740e6 Mon Sep 17 00:00:00 2001 From: Ben Sarmiento Date: Sun, 26 May 2024 04:05:25 +0200 Subject: [PATCH] Change defaults and modify dumped torrents behavior --- internal/config/types.go | 4 ++-- internal/torrent/refresh.go | 16 +++++++++------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/internal/config/types.go b/internal/config/types.go index 744c242..8a54e8d 100644 --- a/internal/config/types.go +++ b/internal/config/types.go @@ -138,14 +138,14 @@ func (z *ZurgConfig) GetDownloadsEveryMins() int { func (z *ZurgConfig) GetDownloadsLimit() int { if z.DownloadsLimit == 0 { - return 50000 + return 10000 } return z.DownloadsLimit } func (z *ZurgConfig) GetDumpTorrentsEveryMins() int { if z.DumpTorrentsEveryMins == 0 { - return 60 + return 1440 } return z.DumpTorrentsEveryMins } diff --git a/internal/torrent/refresh.go b/internal/torrent/refresh.go index 43f3114..57db22c 100644 --- a/internal/torrent/refresh.go +++ b/internal/torrent/refresh.go @@ -36,13 +36,15 @@ func (t *TorrentManager) refreshTorrents() []string { torrent := t.readTorrentFromFile(filePath) if torrent != nil { accessKey := t.GetKey(torrent) - t.log.Debugf("Adding dumped torrent %s", accessKey) - allTorrents.Set(accessKey, torrent) - t.assignDirectory(torrent, func(directory string) { - listing, _ := t.DirectoryMap.Get(directory) - listing.Set(accessKey, torrent) - // note that we're not adding it to updatedPaths - }) + if !allTorrents.Has(accessKey) { + t.log.Debugf("Loading dumped torrent %s", accessKey) + allTorrents.Set(accessKey, torrent) + t.assignDirectory(torrent, func(directory string) { + listing, _ := t.DirectoryMap.Get(directory) + listing.Set(accessKey, torrent) + // note that we're not adding it to updatedPaths + }) + } freshAccessKeys.Add(accessKey) // to prevent being deleted } return false