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

@@ -6,7 +6,6 @@ import (
"path/filepath"
"github.com/debridmediamanager.com/zurg/internal/torrent"
"github.com/debridmediamanager.com/zurg/pkg/davextra"
)
// createMultiTorrentResponse creates a WebDAV response for a list of torrents
@@ -34,7 +33,6 @@ func createMultiTorrentResponse(basePath string, torrents []torrent.Torrent) (st
func createSingleTorrentResponse(basePath string, torrents []torrent.Torrent) (string, error) {
htmlDoc := "<ul>"
nameAndLink := make(map[string]bool)
finalName := make(map[string]bool)
currentPath := filepath.Join(basePath)
@@ -47,16 +45,10 @@ func createSingleTorrentResponse(basePath string, torrents []torrent.Torrent) (s
}
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