Implement new fsm

This commit is contained in:
Ben Sarmiento
2024-05-21 01:59:53 +02:00
parent d5dd9426ed
commit 2c5e7a1db0
14 changed files with 121 additions and 59 deletions

View File

@@ -1,6 +1,7 @@
package dav
import (
"context"
"fmt"
"github.com/debridmediamanager/zurg/internal/config"
@@ -29,14 +30,17 @@ 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.IsDeleted {
if !ok || !file.State.Is("ok") {
return fmt.Errorf("cannot find file %s", fileName)
}
dirCfg := torMgr.Config.(*config.ZurgConfigV1).GetDirectoryConfig(directory)
if dirCfg.OnlyShowTheBiggestFile {
torMgr.Delete(torrentName, true)
} else {
file.IsDeleted = true
err := file.State.Event(context.Background(), "delete")
if err != nil {
return fmt.Errorf("cannot delete file %s: %v", fileName, err)
}
if torMgr.CheckDeletedStatus(torrent) {
torMgr.Delete(torrentName, true)
}