diff --git a/internal/dav/listing.go b/internal/dav/listing.go index 9713c26..0aed8df 100644 --- a/internal/dav/listing.go +++ b/internal/dav/listing.go @@ -7,6 +7,7 @@ import ( "sort" "strings" + "github.com/debridmediamanager/zurg/internal/config" "github.com/debridmediamanager/zurg/internal/torrent" "github.com/debridmediamanager/zurg/pkg/dav" "github.com/debridmediamanager/zurg/pkg/logutil" @@ -64,6 +65,12 @@ func HandleListFiles(directory, torrentName string, torMgr *torrent.TorrentManag return nil, fmt.Errorf("cannot find torrent %s", torrentName) } + dirCfg := torMgr.Config.(*config.ZurgConfigV1).GetDirectoryConfig(directory) + biggestFileSize := int64(0) + if dirCfg.OnlyShowTheBiggestFile { + biggestFileSize = tor.ComputeBiggestFileSize() + } + var buf bytes.Buffer buf.WriteString("") buf.WriteString(dav.BaseDirectory(filepath.Join(directory, tor.AccessKey), tor.LatestAdded)) @@ -74,6 +81,9 @@ func HandleListFiles(directory, torrentName string, torMgr *torrent.TorrentManag if !ok || !strings.HasPrefix(file.Link, "http") { continue } + if dirCfg.OnlyShowTheBiggestFile && file.Bytes < biggestFileSize { + continue + } buf.WriteString(dav.File(filename, file.Bytes, file.Ended)) } buf.WriteString("")