Apply biggest file option to dav mount
This commit is contained in:
@@ -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("<?xml version=\"1.0\" encoding=\"utf-8\"?><d:multistatus xmlns:d=\"DAV:\">")
|
||||
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("</d:multistatus>")
|
||||
|
||||
Reference in New Issue
Block a user