Assign to directories

This commit is contained in:
Ben Sarmiento
2024-05-27 07:36:38 +02:00
parent 9e44721fa2
commit 5c5a73e6e4

View File

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