Clean up grouping logic

This commit is contained in:
Ben Sarmiento
2023-10-18 21:47:57 +02:00
parent 0fa7b407b0
commit ce0b2445b2
4 changed files with 14 additions and 21 deletions

View File

@@ -1,7 +1,6 @@
package dav
import (
"fmt"
"log"
"net/http"
"os"
@@ -17,8 +16,6 @@ func Router(mux *http.ServeMux) {
log.Panicf("Config failed to load: %v", err)
}
fmt.Println("config version", c.GetDirectories())
t := torrent.NewTorrentManager(os.Getenv("RD_TOKEN"), c)
mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {

View File

@@ -23,9 +23,9 @@ func findAllTorrentsWithName(t *torrent.TorrentManager, directory, torrentName s
var matchingTorrents []torrent.Torrent
torrents := t.GetByDirectory(directory)
for _, torrent := range torrents {
if torrent.Name == torrentName || strings.HasPrefix(torrent.Name, torrentName) {
matchingTorrents = append(matchingTorrents, torrent)
for i := range torrents {
if torrents[i].Name == torrentName || strings.HasPrefix(torrents[i].Name, torrentName) {
matchingTorrents = append(matchingTorrents, torrents[i])
}
}