Add setting for hiding broken torrents

This commit is contained in:
Ben Adrian Sarmiento
2024-07-06 23:56:12 +02:00
parent acd18aca9a
commit 1373bbb975
5 changed files with 20 additions and 5 deletions

View File

@@ -59,7 +59,7 @@ func ServeTorrentsListForInfuse(directory string, torMgr *torrent.TorrentManager
return buf.Bytes(), nil
}
func ServeFilesListForInfuse(directory, torrentName string, torMgr *torrent.TorrentManager) ([]byte, error) {
func ServeFilesListForInfuse(directory, torrentName string, torMgr *torrent.TorrentManager, shouldHideBrokenTorrents bool) ([]byte, error) {
torrents, ok := torMgr.DirectoryMap.Get(directory)
if !ok {
return nil, fmt.Errorf("cannot find directory %s", directory)
@@ -88,6 +88,9 @@ func ServeFilesListForInfuse(directory, torrentName string, torMgr *torrent.Torr
if file.State.Is("deleted_file") {
continue
}
if file.State.Is("broken_file") && shouldHideBrokenTorrents {
continue
}
if dirCfg.OnlyShowTheBiggestFile && file.Bytes < biggestFileSize {
continue
}

View File

@@ -54,7 +54,7 @@ func ServeTorrentsList(directory string, torMgr *torrent.TorrentManager) ([]byte
return buf.Bytes(), nil
}
func ServeFilesList(directory, torrentName string, torMgr *torrent.TorrentManager) ([]byte, error) {
func ServeFilesList(directory, torrentName string, torMgr *torrent.TorrentManager, shouldHideBrokenTorrents bool) ([]byte, error) {
torrents, ok := torMgr.DirectoryMap.Get(directory)
if !ok {
return nil, fmt.Errorf("cannot find directory %s", directory)
@@ -80,6 +80,9 @@ func ServeFilesList(directory, torrentName string, torMgr *torrent.TorrentManage
if file.State.Is("deleted_file") {
continue
}
if file.State.Is("broken_file") && shouldHideBrokenTorrents {
continue
}
if dirCfg.OnlyShowTheBiggestFile && file.Bytes < biggestFileSize {
continue
}