Add rename
This commit is contained in:
@@ -11,7 +11,7 @@ import (
|
||||
"github.com/debridmediamanager/zurg/pkg/logutil"
|
||||
)
|
||||
|
||||
func HandleListDirectories(torMgr *torrent.TorrentManager) (*string, error) {
|
||||
func HandleListDirectories(torMgr *torrent.TorrentManager) ([]byte, error) {
|
||||
davDoc := "<?xml version=\"1.0\" encoding=\"utf-8\"?><d:multistatus xmlns:d=\"DAV:\">"
|
||||
davDoc += dav.BaseDirectory("", "")
|
||||
directories := torMgr.DirectoryMap.Keys()
|
||||
@@ -23,10 +23,10 @@ func HandleListDirectories(torMgr *torrent.TorrentManager) (*string, error) {
|
||||
davDoc += dav.Directory(directory, "")
|
||||
}
|
||||
davDoc += "</d:multistatus>"
|
||||
return &davDoc, nil
|
||||
return []byte(davDoc), nil
|
||||
}
|
||||
|
||||
func HandleListTorrents(directory string, torMgr *torrent.TorrentManager, log *logutil.Logger) (*string, error) {
|
||||
func HandleListTorrents(directory string, torMgr *torrent.TorrentManager, log *logutil.Logger) ([]byte, error) {
|
||||
torrents, ok := torMgr.DirectoryMap.Get(directory)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("cannot find directory %s", directory)
|
||||
@@ -48,10 +48,10 @@ func HandleListTorrents(directory string, torMgr *torrent.TorrentManager, log *l
|
||||
davDoc += dav.Directory(tor.AccessKey, tor.LatestAdded)
|
||||
}
|
||||
davDoc += "</d:multistatus>"
|
||||
return &davDoc, nil
|
||||
return []byte(davDoc), nil
|
||||
}
|
||||
|
||||
func HandleListFiles(directory, torrentName string, torMgr *torrent.TorrentManager, log *logutil.Logger) (*string, error) {
|
||||
func HandleListFiles(directory, torrentName string, torMgr *torrent.TorrentManager, log *logutil.Logger) ([]byte, error) {
|
||||
torrents, ok := torMgr.DirectoryMap.Get(directory)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("cannot find directory %s", directory)
|
||||
@@ -72,5 +72,24 @@ func HandleListFiles(directory, torrentName string, torMgr *torrent.TorrentManag
|
||||
davDoc += dav.File(filename, file.Bytes, file.Ended)
|
||||
}
|
||||
davDoc += "</d:multistatus>"
|
||||
return &davDoc, nil
|
||||
return []byte(davDoc), nil
|
||||
}
|
||||
|
||||
func HandlePropfindFile(directory, torrentName, fileName string, torMgr *torrent.TorrentManager, log *logutil.Logger) ([]byte, error) {
|
||||
torrents, ok := torMgr.DirectoryMap.Get(directory)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("cannot find directory %s", directory)
|
||||
}
|
||||
tor, ok := torrents.Get(torrentName)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("cannot find torrent %s", torrentName)
|
||||
}
|
||||
file, ok := tor.SelectedFiles.Get(fileName)
|
||||
if !ok || !strings.HasPrefix(file.Link, "http") {
|
||||
return nil, fmt.Errorf("cannot find file %s", fileName)
|
||||
}
|
||||
davDoc := "<?xml version=\"1.0\" encoding=\"utf-8\"?><d:multistatus xmlns:d=\"DAV:\">" + dav.BaseDirectory(filepath.Join(directory, tor.AccessKey), tor.LatestAdded)
|
||||
davDoc += dav.File(fileName, file.Bytes, file.Ended)
|
||||
davDoc += "</d:multistatus>"
|
||||
return []byte(davDoc), nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user