Fix grouping

This commit is contained in:
Ben Sarmiento
2023-10-18 21:36:40 +02:00
parent 4650213218
commit 0fa7b407b0
3 changed files with 22 additions and 25 deletions

View File

@@ -2,6 +2,7 @@ package torrent
import (
"encoding/gob"
"fmt"
"log"
"os"
"strings"
@@ -50,25 +51,29 @@ func (t *TorrentManager) getAll() []Torrent {
return nil
}
var torrentsV2 []Torrent
for _, torrent := range torrents {
torrentV2 := Torrent{
Torrent: torrent,
SelectedFiles: nil,
}
torrentsV2 = append(torrentsV2, torrentV2)
}
version := t.config.GetVersion()
fmt.Println("config version", version)
if version == "v1" {
configV1 := t.config.(*config.ZurgConfigV1)
groupMap := configV1.GetGroupMap()
for _, directories := range groupMap {
for _, torrent := range torrents {
// process grouping
torrentV2 := Torrent{
Torrent: torrent,
SelectedFiles: nil,
}
for group, directories := range groupMap {
log.Printf("Processing group %s\n", group)
for i := range torrents {
for _, directory := range directories {
if configV1.MeetsConditions(directory, torrent.ID, torrent.Name) {
torrentV2.Directories = append(torrentV2.Directories, directory)
if configV1.MeetsConditions(directory, torrentsV2[i].ID, torrentsV2[i].Name) {
torrentsV2[i].Directories = append(torrentsV2[i].Directories, directory)
fmt.Println(torrentsV2[i].Name, torrentsV2[i].Directories)
break
}
}
torrentsV2 = append(torrentsV2, torrentV2)
}
}
}
@@ -76,10 +81,6 @@ func (t *TorrentManager) getAll() []Torrent {
return torrentsV2
}
func (t *TorrentManager) GetAll() []Torrent {
return t.torrents
}
func (t *TorrentManager) GetByDirectory(directory string) []Torrent {
var torrents []Torrent
for _, torrent := range t.torrents {