Remove ristretto cache
This commit is contained in:
@@ -32,27 +32,21 @@ func HandleListTorrents(directory string, t *torrent.TorrentManager, log *zap.Su
|
||||
return nil, fmt.Errorf("cannot find directory %s", directory)
|
||||
}
|
||||
|
||||
if resp, ok := t.ResponseCache.Get(directory + ".html"); !ok {
|
||||
log.Debugf("Generating html for directory %s", directory)
|
||||
htmlDoc := "<ol>"
|
||||
var allTorrents []*torrent.Torrent
|
||||
torrents.IterCb(func(_ string, tor *torrent.Torrent) {
|
||||
if tor.AllInProgress() {
|
||||
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=\"/http/%s/\">%s</a></li>", filepath.Join(directory, url.PathEscape(tor.AccessKey)), tor.AccessKey)
|
||||
htmlDoc := "<ol>"
|
||||
var allTorrents []*torrent.Torrent
|
||||
torrents.IterCb(func(_ string, tor *torrent.Torrent) {
|
||||
if tor.AllInProgress() {
|
||||
return
|
||||
}
|
||||
return &htmlDoc, nil
|
||||
} else {
|
||||
htmlDoc := resp.(string)
|
||||
return &htmlDoc, nil
|
||||
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=\"/http/%s/\">%s</a></li>", filepath.Join(directory, url.PathEscape(tor.AccessKey)), tor.AccessKey)
|
||||
}
|
||||
return &htmlDoc, nil
|
||||
}
|
||||
|
||||
func HandleListFiles(directory, torrentName string, t *torrent.TorrentManager, log *zap.SugaredLogger) (*string, error) {
|
||||
@@ -65,22 +59,16 @@ func HandleListFiles(directory, torrentName string, t *torrent.TorrentManager, l
|
||||
return nil, fmt.Errorf("cannot find torrent %s", torrentName)
|
||||
}
|
||||
|
||||
if resp, ok := t.ResponseCache.Get(directory + "/" + torrentName + ".html"); !ok {
|
||||
log.Debugf("Generating html for torrent %s", torrentName)
|
||||
htmlDoc := "<ol>"
|
||||
filenames := tor.SelectedFiles.Keys()
|
||||
sort.Strings(filenames)
|
||||
for _, filename := range filenames {
|
||||
file, _ := tor.SelectedFiles.Get(filename)
|
||||
if file == nil || !strings.HasPrefix(file.Link, "http") {
|
||||
continue
|
||||
}
|
||||
filePath := filepath.Join(directory, torrentName, url.PathEscape(filename))
|
||||
htmlDoc += fmt.Sprintf("<li><a href=\"/http/%s\">%s</a></li>", filePath, filename)
|
||||
htmlDoc := "<ol>"
|
||||
filenames := tor.SelectedFiles.Keys()
|
||||
sort.Strings(filenames)
|
||||
for _, filename := range filenames {
|
||||
file, ok := tor.SelectedFiles.Get(filename)
|
||||
if !ok || !strings.HasPrefix(file.Link, "http") {
|
||||
continue
|
||||
}
|
||||
return &htmlDoc, nil
|
||||
} else {
|
||||
htmlDoc := resp.(string)
|
||||
return &htmlDoc, nil
|
||||
filePath := filepath.Join(directory, torrentName, url.PathEscape(filename))
|
||||
htmlDoc += fmt.Sprintf("<li><a href=\"/http/%s\">%s</a></li>", filePath, filename)
|
||||
}
|
||||
return &htmlDoc, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user