Reimplement deletes and marking files as broken

This commit is contained in:
Ben Sarmiento
2024-01-29 22:28:27 +01:00
parent 1615c9e121
commit b505400f60
12 changed files with 64 additions and 112 deletions

View File

@@ -31,11 +31,12 @@ func HandleRenameFile(directory, torrentName, fileName, newName string, torMgr *
return fmt.Errorf("cannot find torrent %s", torrentName)
}
file, ok := torrent.SelectedFiles.Get(fileName)
if !ok {
if !ok || file.IsDeleted {
return fmt.Errorf("cannot find file %s", fileName)
}
torrent.SelectedFiles.Remove(torrentName)
oldName := torMgr.GetPath(file)
file.Rename = newName
torrent.SelectedFiles.Set(newName, file)
file.Path = newName
torrent.SelectedFiles.Remove(oldName)
return nil
}