Handle adds and deletes
This commit is contained in:
@@ -6,20 +6,20 @@ import (
|
||||
"github.com/debridmediamanager/zurg/internal/torrent"
|
||||
)
|
||||
|
||||
func HandleDeleteTorrent(directory, torrentName string, t *torrent.TorrentManager) error {
|
||||
torrents, ok := t.DirectoryMap.Get(directory)
|
||||
func HandleDeleteTorrent(directory, torrentName string, torMgr *torrent.TorrentManager) error {
|
||||
torrents, ok := torMgr.DirectoryMap.Get(directory)
|
||||
if !ok {
|
||||
return fmt.Errorf("cannot find directory %s", directory)
|
||||
}
|
||||
if !torrents.Has(torrentName) {
|
||||
return fmt.Errorf("cannot find torrent %s", torrentName)
|
||||
}
|
||||
t.Delete(torrentName, true)
|
||||
torMgr.Delete(torrentName, true)
|
||||
return nil
|
||||
}
|
||||
|
||||
func HandleDeleteFile(directory, torrentName, fileName string, t *torrent.TorrentManager) error {
|
||||
torrents, ok := t.DirectoryMap.Get(directory)
|
||||
func HandleDeleteFile(directory, torrentName, fileName string, torMgr *torrent.TorrentManager) error {
|
||||
torrents, ok := torMgr.DirectoryMap.Get(directory)
|
||||
if !ok {
|
||||
return fmt.Errorf("cannot find directory %s", directory)
|
||||
}
|
||||
@@ -32,8 +32,8 @@ func HandleDeleteFile(directory, torrentName, fileName string, t *torrent.Torren
|
||||
return fmt.Errorf("cannot find file %s", fileName)
|
||||
}
|
||||
file.Link = "unselect"
|
||||
if t.CheckDeletedState(torrent) {
|
||||
t.Delete(torrentName, true)
|
||||
if torMgr.CheckDeletedState(torrent) {
|
||||
torMgr.Delete(torrentName, true)
|
||||
}
|
||||
// todo: triggeer an update ???
|
||||
// t.TriggerHookOnLibraryUpdate(updatedPaths)
|
||||
|
||||
Reference in New Issue
Block a user