From 5c5a73e6e4a5af0bdce2d256357e075a5a85ca9d Mon Sep 17 00:00:00 2001 From: Ben Sarmiento Date: Mon, 27 May 2024 07:36:38 +0200 Subject: [PATCH] Assign to directories --- internal/torrent/refresh.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/internal/torrent/refresh.go b/internal/torrent/refresh.go index f592939..19eae60 100644 --- a/internal/torrent/refresh.go +++ b/internal/torrent/refresh.go @@ -36,7 +36,14 @@ func (t *TorrentManager) refreshTorrents() []string { t.getTorrentFiles("data").Each(func(filePath string) bool { torrent := t.readTorrentFromFile(filePath) if torrent != nil { - allTorrents.Set(t.GetKey(torrent), torrent) + accessKey := t.GetKey(torrent) + allTorrents.Set(accessKey, torrent) + t.assignDirectory(torrent, func(directory string) { + listing, _ := t.DirectoryMap.Get(directory) + listing.Set(accessKey, torrent) + + updatedPaths.Add(fmt.Sprintf("%s/%s", directory, accessKey)) + }) filename := filepath.Base(filePath) cachedAccessKeys.Add(strings.TrimSuffix(filename, ".zurgtorrent")) }