Fix filenames on webdav issue
This commit is contained in:
@@ -71,16 +71,11 @@ func handleListOfTorrents(requestPath string, t *torrent.TorrentManager) (*strin
|
||||
}
|
||||
|
||||
htmlDoc := "<ol>"
|
||||
|
||||
var accessKeys []string
|
||||
torrents.IterCb(func(accessKey string, _ *torrent.Torrent) {
|
||||
accessKeys = append(accessKeys, accessKey)
|
||||
})
|
||||
accessKeys := torrents.Keys()
|
||||
sort.Strings(accessKeys)
|
||||
for _, accessKey := range accessKeys {
|
||||
htmlDoc = htmlDoc + fmt.Sprintf("<li><a href=\"%s/\">%s</a></li>", filepath.Join(requestPath, url.PathEscape(accessKey)), accessKey)
|
||||
}
|
||||
|
||||
return &htmlDoc, nil
|
||||
}
|
||||
|
||||
@@ -97,16 +92,17 @@ func handleSingleTorrent(requestPath string, t *torrent.TorrentManager) (*string
|
||||
}
|
||||
|
||||
htmlDoc := "<ol>"
|
||||
|
||||
tor.SelectedFiles.IterCb(func(filename string, file *torrent.File) {
|
||||
filenames := tor.SelectedFiles.Keys()
|
||||
sort.Strings(filenames)
|
||||
for _, filename := range filenames {
|
||||
file, _ := tor.SelectedFiles.Get(filename)
|
||||
if file.Link == "" {
|
||||
// will be caught by torrent manager's repairAll
|
||||
// just skip it for now
|
||||
return
|
||||
continue
|
||||
}
|
||||
filePath := filepath.Join(requestPath, url.PathEscape(filename))
|
||||
htmlDoc += fmt.Sprintf("<li><a href=\"%s\">%s</a></li>", filePath, filename)
|
||||
})
|
||||
|
||||
}
|
||||
return &htmlDoc, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user