mirror of
https://github.com/NCBM/plyngent.git
synced 2026-11-07 15:37:55 +08:00
core/tools: send a deleted path to the system trash
`delete_path` is the only destructive file entry point the agent has, and it carries `ToolTag.YOLO` — under `--yes` / `/yolo` it runs with no confirmation at all. A delete is now a move into the desktop's own trash (freedesktop trash on Linux, Finder trash on macOS, Recycle Bin on Windows) through `send2trash`, so the human can put the file back with the file manager they already have. The new `permanent=true` argument is the old behaviour, chosen on purpose. A trashing that fails is reported, never downgraded to a deletion: the human was told the path is recoverable, so a volume with no writable trash directory leaves the file where it is and the error names `permanent=true` as the way to delete it anyway. A broken install (the library is a required dependency) is reported the same way. Scratch paths under the OS temporary directory are still deleted for good — nobody restores them, and a trash on the `/tmp` volume would only collect them. The rule now lives in `tools/trash.py` (`under_system_temp`) and the temporary workspace cleanup uses it too, instead of keeping a second copy of the check.
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
# Minimal stubs for ``send2trash`` (a required dependency).
|
||||
# Only the surface ``plyngent.tools.trash`` uses is declared; the real package is
|
||||
# pure Python over ctypes (freedesktop trash spec / Finder trash / Recycle Bin).
|
||||
|
||||
from collections.abc import Iterable
|
||||
|
||||
class TrashPermissionError(PermissionError): ...
|
||||
|
||||
def send2trash(paths: str | Iterable[str]) -> None: ...
|
||||
Reference in New Issue
Block a user