List broken files but dont serve them

This commit is contained in:
Ben Adrian Sarmiento
2024-06-26 10:44:16 +02:00
parent e4650a0f0f
commit d5e3665a53
8 changed files with 12 additions and 19 deletions

View File

@@ -30,7 +30,7 @@ func HandleDeleteFile(directory, torrentName, fileName string, torMgr *torrent.T
return fmt.Errorf("cannot find torrent %s", torrentName)
}
file, ok := torrent.SelectedFiles.Get(fileName)
if !ok || !file.State.Is("ok_file") {
if !ok || file.State.Is("deleted_file") {
return fmt.Errorf("cannot find file %s", fileName)
}
dirCfg := torMgr.Config.(*config.ZurgConfigV1).GetDirectoryConfig(directory)

View File

@@ -85,7 +85,7 @@ func ServeFilesListForInfuse(directory, torrentName string, torMgr *torrent.Torr
for _, filename := range filenames {
file, _ := tor.SelectedFiles.Get(filename)
if !file.State.Is("ok_file") {
if file.State.Is("deleted_file") {
continue
}
if dirCfg.OnlyShowTheBiggestFile && file.Bytes < biggestFileSize {

View File

@@ -77,7 +77,7 @@ func ServeFilesList(directory, torrentName string, torMgr *torrent.TorrentManage
sort.Strings(filenames)
for _, filename := range filenames {
file, _ := tor.SelectedFiles.Get(filename)
if !file.State.Is("ok_file") {
if file.State.Is("deleted_file") {
continue
}
if dirCfg.OnlyShowTheBiggestFile && file.Bytes < biggestFileSize {
@@ -105,7 +105,7 @@ func HandleSingleFile(directory, torrentName, fileName string, torMgr *torrent.T
return nil, fmt.Errorf("cannot find torrent %s", torrentName)
}
file, ok := tor.SelectedFiles.Get(fileName)
if !ok || !file.State.Is("ok_file") {
if !ok || file.State.Is("deleted_file") {
return nil, fmt.Errorf("cannot find file %s", fileName)
}

View File

@@ -31,7 +31,7 @@ func HandleRenameFile(directory, torrentName, fileName, newName string, torMgr *
return fmt.Errorf("cannot find torrent %s", torrentName)
}
file, ok := torrent.SelectedFiles.Get(fileName)
if !ok || !file.State.Is("ok_file") {
if !ok || file.State.Is("deleted_file") {
return fmt.Errorf("cannot find file %s", fileName)
}
oldName := torMgr.GetPath(file)