Add caching

This commit is contained in:
Ben Sarmiento
2023-10-22 13:29:41 +02:00
parent c789ebc96d
commit 6eccba394c
9 changed files with 74 additions and 55 deletions

View File

@@ -20,14 +20,12 @@ func convertRFC3339toRFC1123(input string) string {
// findAllTorrentsWithName finds all torrents in a given directory with a given name
func findAllTorrentsWithName(t *torrent.TorrentManager, directory, torrentName string) []torrent.Torrent {
var matchingTorrents []torrent.Torrent
matchingTorrents := make([]torrent.Torrent, 0, 10)
torrents := t.GetByDirectory(directory)
for i := range torrents {
if torrents[i].Name == torrentName || strings.HasPrefix(torrents[i].Name, torrentName) {
matchingTorrents = append(matchingTorrents, torrents[i])
}
}
return matchingTorrents
}