Rewrite state machines

This commit is contained in:
Ben Sarmiento
2024-05-21 17:07:40 +02:00
parent 6c24d74f61
commit 0743b01223
12 changed files with 69 additions and 55 deletions

View File

@@ -30,14 +30,14 @@ 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") {
if !ok || !file.State.Is("ok_file") {
return fmt.Errorf("cannot find file %s", fileName)
}
dirCfg := torMgr.Config.(*config.ZurgConfigV1).GetDirectoryConfig(directory)
if dirCfg.OnlyShowTheBiggestFile {
torMgr.Delete(torrentName, true)
} else {
err := file.State.Event(context.Background(), "delete")
err := file.State.Event(context.Background(), "delete_file")
if err != nil {
return fmt.Errorf("cannot delete file %s: %v", fileName, err)
}