Support filtering by size
This commit is contained in:
@@ -8,10 +8,12 @@ type ZurgConfigV1 struct {
|
||||
log *logutil.Logger
|
||||
}
|
||||
type Directory struct {
|
||||
GroupOrder int `yaml:"group_order"`
|
||||
Group string `yaml:"group"`
|
||||
Filters []*FilterConditionsV1 `yaml:"filters"`
|
||||
OnlyShowTheBiggestFile bool `yaml:"only_show_the_biggest_file"`
|
||||
GroupOrder int `yaml:"group_order"`
|
||||
Group string `yaml:"group"`
|
||||
Filters []*FilterConditionsV1 `yaml:"filters"`
|
||||
OnlyShowTheBiggestFile bool `yaml:"only_show_the_biggest_file"`
|
||||
OnlyShowFilesWithSizeLte int64 `yaml:"only_show_files_with_size_lte"`
|
||||
OnlyShowFilesWithSizeGte int64 `yaml:"only_show_files_with_size_gte"`
|
||||
}
|
||||
|
||||
type FilterConditionsV1 struct {
|
||||
|
||||
@@ -76,6 +76,12 @@ func ServeFilesListForInfuse(directory, torrentName string, torMgr *torrent.Torr
|
||||
if dirCfg.OnlyShowTheBiggestFile && file.Bytes < biggestFileSize {
|
||||
continue
|
||||
}
|
||||
if dirCfg.OnlyShowFilesWithSizeLte > 0 && file.Bytes > dirCfg.OnlyShowFilesWithSizeLte {
|
||||
continue
|
||||
}
|
||||
if dirCfg.OnlyShowFilesWithSizeGte > 0 && file.Bytes < dirCfg.OnlyShowFilesWithSizeGte {
|
||||
continue
|
||||
}
|
||||
buf.WriteString(dav.File(filename, file.Bytes, file.Ended))
|
||||
}
|
||||
buf.WriteString("</d:multistatus>")
|
||||
|
||||
@@ -80,6 +80,12 @@ func ServeFilesList(directory, torrentName string, torMgr *torrent.TorrentManage
|
||||
if dirCfg.OnlyShowTheBiggestFile && file.Bytes < biggestFileSize {
|
||||
continue
|
||||
}
|
||||
if dirCfg.OnlyShowFilesWithSizeLte > 0 && file.Bytes > dirCfg.OnlyShowFilesWithSizeLte {
|
||||
continue
|
||||
}
|
||||
if dirCfg.OnlyShowFilesWithSizeGte > 0 && file.Bytes < dirCfg.OnlyShowFilesWithSizeGte {
|
||||
continue
|
||||
}
|
||||
buf.WriteString(dav.File(filename, file.Bytes, file.Ended))
|
||||
}
|
||||
buf.WriteString("</d:multistatus>")
|
||||
|
||||
@@ -77,6 +77,12 @@ func ServeFilesList(directory, torrentName string, torMgr *torrent.TorrentManage
|
||||
if dirCfg.OnlyShowTheBiggestFile && file.Bytes < biggestFileSize {
|
||||
continue
|
||||
}
|
||||
if dirCfg.OnlyShowFilesWithSizeLte > 0 && file.Bytes > dirCfg.OnlyShowFilesWithSizeLte {
|
||||
continue
|
||||
}
|
||||
if dirCfg.OnlyShowFilesWithSizeGte > 0 && file.Bytes < dirCfg.OnlyShowFilesWithSizeGte {
|
||||
continue
|
||||
}
|
||||
filePath := filepath.Join(directory, torrentName, url.PathEscape(filename))
|
||||
buf.WriteString(fmt.Sprintf("<li><a href=\"/http/%s\">%s</a></li>", filePath, filename))
|
||||
}
|
||||
|
||||
@@ -141,7 +141,8 @@ func (t *TorrentManager) assignedDirectoryCb(tor *Torrent, cb func(string)) {
|
||||
if unplayable {
|
||||
cb(config.UNPLAYABLE_TORRENTS)
|
||||
break
|
||||
} else if t.Config.MeetsConditions(directory, tor.AccessKey, tor.ComputeTotalSize(), torrentIDs, filenames, fileSizes) {
|
||||
}
|
||||
if t.Config.MeetsConditions(directory, tor.AccessKey, tor.ComputeTotalSize(), torrentIDs, filenames, fileSizes) {
|
||||
cb(directory)
|
||||
break
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user