Only add DMM fragment when there is the same filename in the directory
This commit is contained in:
@@ -43,7 +43,8 @@ func createSingleTorrentResponse(basePath string, torrents []torrent.Torrent, t
|
||||
currentPath := filepath.Join(basePath, torrents[0].Name)
|
||||
responses = append(responses, dav.Directory(currentPath))
|
||||
|
||||
seen := make(map[string]bool)
|
||||
nameAndLink := make(map[string]bool)
|
||||
finalName := make(map[string]bool)
|
||||
|
||||
var torrentResponses []dav.Response
|
||||
for _, torrent := range torrents {
|
||||
@@ -57,12 +58,15 @@ func createSingleTorrentResponse(basePath string, torrents []torrent.Torrent, t
|
||||
continue
|
||||
}
|
||||
filename := filepath.Base(file.Path)
|
||||
fragment := davextra.GetLinkFragment(file.Link)
|
||||
filename = davextra.InsertLinkFragment(filename, fragment)
|
||||
if _, exists := seen[filename]; exists {
|
||||
if _, exists := nameAndLink[filename+file.Link]; exists {
|
||||
continue
|
||||
}
|
||||
seen[filename] = true
|
||||
nameAndLink[filename+file.Link] = true
|
||||
if _, exists := finalName[filename]; exists {
|
||||
fragment := davextra.GetLinkFragment(file.Link)
|
||||
filename = davextra.InsertLinkFragment(filename, fragment)
|
||||
}
|
||||
finalName[filename] = true
|
||||
filePath := filepath.Join(currentPath, filename)
|
||||
torrentResponses = append(torrentResponses, dav.File(
|
||||
filePath,
|
||||
|
||||
Reference in New Issue
Block a user