Skip in progress torrents when listing
This commit is contained in:
@@ -72,6 +72,9 @@ func handleListTorrents(w http.ResponseWriter, requestPath string, t *torrent.To
|
|||||||
|
|
||||||
var allTorrents []*torrent.Torrent
|
var allTorrents []*torrent.Torrent
|
||||||
torrents.IterCb(func(_ string, tor *torrent.Torrent) {
|
torrents.IterCb(func(_ string, tor *torrent.Torrent) {
|
||||||
|
if tor.InProgress() {
|
||||||
|
return
|
||||||
|
}
|
||||||
allTorrents = append(allTorrents, tor)
|
allTorrents = append(allTorrents, tor)
|
||||||
})
|
})
|
||||||
sort.Slice(allTorrents, func(i, j int) bool {
|
sort.Slice(allTorrents, func(i, j int) bool {
|
||||||
|
|||||||
@@ -71,10 +71,20 @@ func handleListOfTorrents(requestPath string, t *torrent.TorrentManager) (*strin
|
|||||||
}
|
}
|
||||||
|
|
||||||
htmlDoc := "<ol>"
|
htmlDoc := "<ol>"
|
||||||
accessKeys := torrents.Keys()
|
|
||||||
sort.Strings(accessKeys)
|
var allTorrents []*torrent.Torrent
|
||||||
for _, accessKey := range accessKeys {
|
torrents.IterCb(func(_ string, tor *torrent.Torrent) {
|
||||||
htmlDoc = htmlDoc + fmt.Sprintf("<li><a href=\"%s/\">%s</a></li>", filepath.Join(requestPath, url.PathEscape(accessKey)), accessKey)
|
if tor.InProgress() {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
allTorrents = append(allTorrents, tor)
|
||||||
|
})
|
||||||
|
sort.Slice(allTorrents, func(i, j int) bool {
|
||||||
|
return allTorrents[i].AccessKey < allTorrents[j].AccessKey
|
||||||
|
})
|
||||||
|
|
||||||
|
for _, tor := range allTorrents {
|
||||||
|
htmlDoc = htmlDoc + fmt.Sprintf("<li><a href=\"%s/\">%s</a></li>", filepath.Join(requestPath, url.PathEscape(tor.AccessKey)), tor.AccessKey)
|
||||||
}
|
}
|
||||||
return &htmlDoc, nil
|
return &htmlDoc, nil
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user