Fix rewrites

This commit is contained in:
Ben Sarmiento
2024-05-22 02:26:20 +02:00
parent a9cc689702
commit 9990bf90ca
10 changed files with 149 additions and 114 deletions

View File

@@ -2,15 +2,20 @@ package torrent
import (
"fmt"
"strings"
"sort"
)
func getFileIDs(files []*File) string {
var fileIDs []string
func getFileIDs(files []*File) []string {
var fileIDs []int
for _, file := range files {
if file.ID != 0 {
fileIDs = append(fileIDs, fmt.Sprintf("%d", file.ID))
fileIDs = append(fileIDs, file.ID)
}
}
return strings.Join(fileIDs, ",")
sort.Ints(fileIDs)
var ret []string
for _, id := range fileIDs {
ret = append(ret, fmt.Sprintf("%d", id))
}
return ret
}