Add accidental removal fix
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package torrent
|
||||
|
||||
import (
|
||||
"github.com/debridmediamanager/zurg/internal/config"
|
||||
cmap "github.com/orcaman/concurrent-map/v2"
|
||||
)
|
||||
|
||||
@@ -32,8 +33,12 @@ func (t *TorrentManager) Delete(accessKey string, deleteInRD bool) {
|
||||
}
|
||||
// t.log.Infof("Removing torrent %s from zurg database (not real-debrid)", accessKey)
|
||||
t.DirectoryMap.IterCb(func(directory string, torrents cmap.ConcurrentMap[string, *Torrent]) {
|
||||
if directory == config.DOWNLOADS || directory == config.DUMPED_TORRENTS {
|
||||
return
|
||||
}
|
||||
torrents.Remove(accessKey)
|
||||
})
|
||||
|
||||
allTorrents.Remove(accessKey)
|
||||
}
|
||||
|
||||
|
||||
@@ -535,8 +535,12 @@ func (t *TorrentManager) initializeDirectoryMaps() {
|
||||
// create directory maps
|
||||
for _, directory := range t.Config.GetDirectories() {
|
||||
t.DirectoryMap.Set(directory, cmap.New[*Torrent]())
|
||||
// t.RootNode.AddChild(fs.NewFileNode(directory, true))
|
||||
}
|
||||
// create special directories
|
||||
t.DirectoryMap.Set(config.ALL_TORRENTS, cmap.New[*Torrent]())
|
||||
t.DirectoryMap.Set(config.DOWNLOADS, cmap.New[*Torrent]())
|
||||
t.DirectoryMap.Set(config.DUMPED_TORRENTS, cmap.New[*Torrent]())
|
||||
t.DirectoryMap.Set(config.UNPLAYABLE_TORRENTS, cmap.New[*Torrent]())
|
||||
}
|
||||
|
||||
func (t *TorrentManager) getTorrentFilename(torrent *Torrent) string {
|
||||
|
||||
@@ -357,7 +357,7 @@ func (t *TorrentManager) assignDirectory(tor *Torrent, triggerHook bool, outputL
|
||||
accessKey := t.GetKey(tor)
|
||||
|
||||
t.DirectoryMap.IterCb(func(directory string, torrents cmap.ConcurrentMap[string, *Torrent]) {
|
||||
if strings.HasPrefix(directory, "int__") {
|
||||
if directory == config.DOWNLOADS || directory == config.DUMPED_TORRENTS {
|
||||
return
|
||||
}
|
||||
torrents.Remove(accessKey)
|
||||
|
||||
@@ -590,13 +590,10 @@ func (t *TorrentManager) canCapacityHandle() bool {
|
||||
}
|
||||
|
||||
func (t *TorrentManager) markAsUnplayable(torrent *Torrent) {
|
||||
// reassign to unplayable torrents directory
|
||||
t.DirectoryMap.IterCb(func(directory string, torrents cmap.ConcurrentMap[string, *Torrent]) {
|
||||
if strings.HasPrefix(directory, "int__") {
|
||||
return
|
||||
}
|
||||
for _, directory := range t.Config.GetDirectories() {
|
||||
torrents, _ := t.DirectoryMap.Get(directory)
|
||||
torrents.Remove(t.GetKey(torrent))
|
||||
})
|
||||
}
|
||||
torrents, _ := t.DirectoryMap.Get(config.UNPLAYABLE_TORRENTS)
|
||||
torrents.Set(t.GetKey(torrent), torrent)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user