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)
|
currentPath := filepath.Join(basePath, torrents[0].Name)
|
||||||
responses = append(responses, dav.Directory(currentPath))
|
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
|
var torrentResponses []dav.Response
|
||||||
for _, torrent := range torrents {
|
for _, torrent := range torrents {
|
||||||
@@ -57,12 +58,15 @@ func createSingleTorrentResponse(basePath string, torrents []torrent.Torrent, t
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
filename := filepath.Base(file.Path)
|
filename := filepath.Base(file.Path)
|
||||||
fragment := davextra.GetLinkFragment(file.Link)
|
if _, exists := nameAndLink[filename+file.Link]; exists {
|
||||||
filename = davextra.InsertLinkFragment(filename, fragment)
|
|
||||||
if _, exists := seen[filename]; exists {
|
|
||||||
continue
|
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)
|
filePath := filepath.Join(currentPath, filename)
|
||||||
torrentResponses = append(torrentResponses, dav.File(
|
torrentResponses = append(torrentResponses, dav.File(
|
||||||
filePath,
|
filePath,
|
||||||
|
|||||||
Reference in New Issue
Block a user