Add file size gte
This commit is contained in:
@@ -3,6 +3,7 @@ package torrent
|
||||
import (
|
||||
"io"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"github.com/debridmediamanager/zurg/internal/config"
|
||||
@@ -120,14 +121,19 @@ func (t *TorrentManager) TriggerHookOnLibraryUpdate(updatedPaths []string) {
|
||||
func (t *TorrentManager) assignedDirectoryCb(tor *Torrent, cb func(string)) {
|
||||
torrentIDs := strset.Union(tor.DownloadedIDs, tor.InProgressIDs).List()
|
||||
// get filenames needed for directory conditions
|
||||
filenames := tor.SelectedFiles.Keys()
|
||||
var filenames []string
|
||||
var fileSizes []int64
|
||||
tor.SelectedFiles.IterCb(func(key string, file *File) {
|
||||
filenames = append(filenames, filepath.Base(file.Path))
|
||||
fileSizes = append(fileSizes, file.Bytes)
|
||||
})
|
||||
// Map torrents to directories
|
||||
switch t.Config.GetVersion() {
|
||||
case "v1":
|
||||
configV1 := t.Config.(*config.ZurgConfigV1)
|
||||
for _, directories := range configV1.GetGroupMap() {
|
||||
for _, directory := range directories {
|
||||
if t.Config.MeetsConditions(directory, tor.AccessKey, torrentIDs, filenames) {
|
||||
if t.Config.MeetsConditions(directory, tor.AccessKey, tor.ComputeTotalSize(), torrentIDs, filenames, fileSizes) {
|
||||
cb(directory)
|
||||
break
|
||||
}
|
||||
|
||||
@@ -104,6 +104,14 @@ func (t *Torrent) AllInProgress() bool {
|
||||
return t.DownloadedIDs.IsEmpty()
|
||||
}
|
||||
|
||||
func (t *Torrent) ComputeTotalSize() int64 {
|
||||
totalSize := int64(0)
|
||||
t.SelectedFiles.IterCb(func(key string, value *File) {
|
||||
totalSize += value.Bytes
|
||||
})
|
||||
return totalSize
|
||||
}
|
||||
|
||||
type File struct {
|
||||
realdebrid.File
|
||||
Added string `json:"Added"`
|
||||
|
||||
Reference in New Issue
Block a user