Fix grouping
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user