A lot of fixes: filenames, dupes in directories, dupes in torrents

This commit is contained in:
Ben Sarmiento
2023-10-28 02:49:49 +02:00
parent ecf82c0131
commit ce6729ade9
4 changed files with 46 additions and 41 deletions

View File

@@ -5,7 +5,6 @@ import (
"github.com/debridmediamanager.com/zurg/internal/torrent"
"github.com/debridmediamanager.com/zurg/pkg/dav"
"github.com/debridmediamanager.com/zurg/pkg/davextra"
)
// createMultiTorrentResponse creates a WebDAV response for a list of torrents
@@ -43,7 +42,6 @@ func createSingleTorrentResponse(basePath string, torrents []torrent.Torrent) (*
currentPath := filepath.Join(basePath, torrents[0].Name)
responses = append(responses, dav.Directory(currentPath))
nameAndLink := make(map[string]bool)
finalName := make(map[string]bool)
var torrentResponses []dav.Response
@@ -56,16 +54,10 @@ func createSingleTorrentResponse(basePath string, torrents []torrent.Torrent) (*
}
filename := filepath.Base(file.Path)
key := filename + file.Link
if nameAndLink[key] {
continue
}
nameAndLink[key] = true
if finalName[filename] {
fragment := davextra.GetLinkFragment(file.Link)
filename = davextra.InsertLinkFragment(filename, fragment)
// fragment := davextra.GetLinkFragment(file.Link)
// filename = davextra.InsertLinkFragment(filename, fragment)
continue
}
finalName[filename] = true