Add support for configs
This commit is contained in:
@@ -9,9 +9,9 @@ import (
|
||||
)
|
||||
|
||||
// createMultiTorrentResponse creates a WebDAV response for a list of torrents
|
||||
func createMultiTorrentResponse(torrents []torrent.Torrent) (*dav.MultiStatus, error) {
|
||||
func createMultiTorrentResponse(basePath string, torrents []torrent.Torrent) (*dav.MultiStatus, error) {
|
||||
var responses []dav.Response
|
||||
responses = append(responses, dav.Directory("/torrents"))
|
||||
responses = append(responses, dav.Directory(basePath))
|
||||
|
||||
seen := make(map[string]bool)
|
||||
|
||||
@@ -19,12 +19,12 @@ func createMultiTorrentResponse(torrents []torrent.Torrent) (*dav.MultiStatus, e
|
||||
if item.Progress != 100 {
|
||||
continue
|
||||
}
|
||||
if _, exists := seen[item.Filename]; exists {
|
||||
if _, exists := seen[item.Name]; exists {
|
||||
continue
|
||||
}
|
||||
seen[item.Filename] = true
|
||||
seen[item.Name] = true
|
||||
|
||||
path := filepath.Join("/torrents", item.Filename)
|
||||
path := filepath.Join(basePath, item.Name)
|
||||
responses = append(responses, dav.Directory(path))
|
||||
}
|
||||
|
||||
@@ -36,10 +36,10 @@ func createMultiTorrentResponse(torrents []torrent.Torrent) (*dav.MultiStatus, e
|
||||
|
||||
// createTorrentResponse creates a WebDAV response for a single torrent
|
||||
// but it also handles the case where there are many torrents with the same name
|
||||
func createCombinedTorrentResponse(torrents []torrent.Torrent, t *torrent.TorrentManager) (*dav.MultiStatus, error) {
|
||||
func createSingleTorrentResponse(basePath string, torrents []torrent.Torrent, t *torrent.TorrentManager) (*dav.MultiStatus, error) {
|
||||
var responses []dav.Response
|
||||
// initial response is the directory itself
|
||||
currentPath := filepath.Join("/torrents", torrents[0].Filename)
|
||||
currentPath := filepath.Join(basePath, torrents[0].Name)
|
||||
responses = append(responses, dav.Directory(currentPath))
|
||||
|
||||
seen := make(map[string]bool)
|
||||
|
||||
Reference in New Issue
Block a user