Rewrite state machines
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@ func ServeFilesListForInfuse(directory, torrentName string, torMgr *torrent.Torr
|
||||
sort.Strings(filenames)
|
||||
for _, filename := range filenames {
|
||||
file, _ := tor.SelectedFiles.Get(filename)
|
||||
if !file.State.Is("ok") {
|
||||
if !file.State.Is("ok_file") {
|
||||
continue
|
||||
}
|
||||
if dirCfg.OnlyShowTheBiggestFile && file.Bytes < biggestFileSize {
|
||||
|
||||
@@ -79,7 +79,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") {
|
||||
if !file.State.Is("ok_file") {
|
||||
continue
|
||||
}
|
||||
if dirCfg.OnlyShowTheBiggestFile && file.Bytes < biggestFileSize {
|
||||
@@ -107,7 +107,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") {
|
||||
if !ok || !file.State.Is("ok_file") {
|
||||
return nil, fmt.Errorf("cannot find file %s", fileName)
|
||||
}
|
||||
|
||||
|
||||
@@ -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") {
|
||||
if !ok || !file.State.Is("ok_file") {
|
||||
return fmt.Errorf("cannot find file %s", fileName)
|
||||
}
|
||||
oldName := torMgr.GetPath(file)
|
||||
|
||||
Reference in New Issue
Block a user