package dav import ( "fmt" "github.com/debridmediamanager/zurg/internal/torrent" ) func HandleRenameTorrent(directory, torrentName, newName string, torMgr *torrent.TorrentManager) error { torrents, ok := torMgr.DirectoryMap.Get(directory) if !ok { return fmt.Errorf("cannot find directory %s", directory) } torrent, ok := torrents.Get(torrentName) if !ok { return fmt.Errorf("cannot find torrent %s", torrentName) } torrents.Remove(torrentName) torrents.Set(newName, torrent) torrent.Rename = newName return nil } func HandleRenameFile(directory, torrentName, fileName, newName string, torMgr *torrent.TorrentManager) error { torrents, ok := torMgr.DirectoryMap.Get(directory) if !ok { return fmt.Errorf("cannot find directory %s", directory) } torrent, ok := torrents.Get(torrentName) if !ok { return fmt.Errorf("cannot find torrent %s", torrentName) } file, ok := torrent.SelectedFiles.Get(fileName) if !ok { return fmt.Errorf("cannot find file %s", fileName) } torrent.SelectedFiles.Remove(torrentName) torrent.SelectedFiles.Set(newName, file) file.Path = newName return nil }