Performance improvements; import speedup

This commit is contained in:
Mukhtar Akere
2025-04-03 11:24:30 +01:00
parent 7d954052ae
commit 4659cd4273
16 changed files with 273 additions and 192 deletions

View File

@@ -2,6 +2,7 @@ package types
import (
"fmt"
"github.com/sirrobot01/debrid-blackhole/internal/config"
"github.com/sirrobot01/debrid-blackhole/internal/logger"
"github.com/sirrobot01/debrid-blackhole/internal/utils"
"github.com/sirrobot01/debrid-blackhole/pkg/arr"
@@ -80,6 +81,26 @@ type File struct {
Generated time.Time `json:"generated"`
}
func (f *File) IsValid() bool {
cfg := config.Get()
name := filepath.Base(f.Path)
if utils.IsSampleFile(f.Path) {
return false
}
if !cfg.IsAllowedFile(name) {
return false
}
if !cfg.IsSizeAllowed(f.Size) {
return false
}
if f.Link == "" {
return false
}
return true
}
func (t *Torrent) Cleanup(remove bool) {
if remove {
err := os.Remove(t.Filename)