Access key computation without clearing data

This commit is contained in:
Ben Sarmiento
2024-01-10 02:36:12 +01:00
parent 91f6d35831
commit ed87c2bbcc
12 changed files with 146 additions and 78 deletions

View File

@@ -47,7 +47,7 @@ func ServeTorrentsListForInfuse(directory string, torMgr *torrent.TorrentManager
if !ok || tor.AllInProgress() {
continue
}
buf.WriteString(dav.BaseDirectory(tor.AccessKey, tor.LatestAdded))
buf.WriteString(dav.BaseDirectory(torMgr.GetKey(tor), tor.LatestAdded))
}
buf.WriteString("</d:multistatus>")
return buf.Bytes(), nil

View File

@@ -50,7 +50,7 @@ func ServeTorrentsList(directory string, torMgr *torrent.TorrentManager) ([]byte
if !ok || tor.AllInProgress() {
continue
}
buf.WriteString(dav.Directory(tor.AccessKey, tor.LatestAdded))
buf.WriteString(dav.Directory(torMgr.GetKey(tor), tor.LatestAdded))
}
buf.WriteString("</d:multistatus>")
return buf.Bytes(), nil
@@ -74,7 +74,7 @@ func ServeFilesList(directory, torrentName string, torMgr *torrent.TorrentManage
var buf bytes.Buffer
buf.WriteString("<?xml version=\"1.0\" encoding=\"utf-8\"?><d:multistatus xmlns:d=\"DAV:\">")
buf.WriteString(dav.BaseDirectory(filepath.Join(directory, tor.AccessKey), tor.LatestAdded))
buf.WriteString(dav.BaseDirectory(filepath.Join(directory, torMgr.GetKey(tor)), tor.LatestAdded))
filenames := tor.SelectedFiles.Keys()
sort.Strings(filenames)
for _, filename := range filenames {
@@ -113,7 +113,7 @@ func HandleSingleFile(directory, torrentName, fileName string, torMgr *torrent.T
var buf bytes.Buffer
buf.WriteString("<?xml version=\"1.0\" encoding=\"utf-8\"?><d:multistatus xmlns:d=\"DAV:\">")
buf.WriteString(dav.BaseDirectory(filepath.Join(directory, tor.AccessKey), tor.LatestAdded))
buf.WriteString(dav.BaseDirectory(filepath.Join(directory, torMgr.GetKey(tor)), tor.LatestAdded))
buf.WriteString(dav.File(fileName, file.Bytes, file.Ended))
buf.WriteString("</d:multistatus>")
return buf.Bytes(), nil

View File

@@ -17,7 +17,7 @@ func HandleRenameTorrent(directory, torrentName, newName string, torMgr *torrent
}
torrents.Remove(torrentName)
torrents.Set(newName, torrent)
torrent.AccessKey = newName
torrent.Rename = newName
return nil
}