Compare commits

...
Author SHA1 Message Date
Vito 1d509c885e chore: release 3.7.0 (refuse permanent delete off Linux/BSD, #644) (#645)
* fix(images): refuse permanent delete where the review does not offer it (#644)

The apply accepted mode "permanent" on every OS; only the workspace hid
the option. A direct call on Windows or macOS unlinked files although the
README says Windows can only remove images from the library. The apply now
answers 400 unless the Freedesktop trash backend is in use, before any
backup or file change. The review and the apply share one check.

The README describes the new option and its limit.

* chore: release 3.7.0
2026-11-17 22:02:44 +00:00
5 changed files with 40 additions and 7 deletions
+2 -1
View File
@@ -103,7 +103,7 @@ Pick an open ComfyUI window and a node, then review the exact before and after.
### Deletes you can review
Choose what happens to the files before anything is removed: remove the image from the library and leave the file on disk, or on Linux and macOS also move it to the system trash. On Windows, images can only be removed from the library. A safety backup of the database is on by default, and removed images can be brought back.
Choose what happens to the files before anything is removed: remove the image from the library and leave the file on disk, or on Linux and macOS also move it to the system trash. On a Linux or BSD server you can also delete the files permanently, for headless servers where a trash only fills up the disk; those files can't be recovered. On Windows, images can only be removed from the library. A safety backup of the database is on by default, and removed images can be brought back.
![Delete dialog offering to remove from the library only or move files to the trash](assets/readme/delete-review.webp)
@@ -230,6 +230,7 @@ The documentation for those pages is in [README-legacy.md](README-legacy.md).
## Known limits
- **Trash is Linux and macOS only.** Windows has no Recycle Bin option, because the bin can delete large files permanently without warning. On Windows you can only remove an image from the library, and the file stays on disk. Where a move to the trash isn't possible on Linux or macOS, the dialog lists why for each file.
- **Permanent delete is Linux and BSD only,** and can't be undone. The safety backup brings back the library records, not the files.
- **Show in folder** opens the file manager on the machine running ComfyUI, not necessarily the one with your browser.
- **Returned images** get their prompt links back, but not their tags, categories, collections or favorites.
- **Inspect a file** doesn't add the file to your library.
+7 -1
View File
@@ -290,7 +290,7 @@ class ImageDeleteMixin:
acted.append(target)
counted = db.count_removal_records([t["removal"] for t in acted])
library_count = len(acted)
permanent_supported = isinstance(trash.BACKEND, trash.FreedesktopBackend)
permanent_supported = permanent_delete_supported()
public = {
"operation": IMAGE_DELETE,
"scope": {"count": library_count, "label": "images"},
@@ -570,6 +570,12 @@ class ImageDeleteMixin:
return [path for path in paths if not removed(path)]
def permanent_delete_supported() -> bool:
"""Permanent delete is offered only with the Freedesktop trash backend
(Linux/BSD servers); the review and the apply both ask here (#644)."""
return isinstance(trash.BACKEND, trash.FreedesktopBackend)
def parse_mode(value):
"""The apply's ``mode``, or None when it is not one of MODES."""
return value if isinstance(value, str) and value in MODES else None
+7 -2
View File
@@ -516,7 +516,7 @@ class MaintenanceRoutesMixin:
# ── apply ─────────────────────────────────────────────────────────
async def apply_maintenance_plan(self, request):
from .image_delete import IMAGE_DELETE, parse_mode
from .image_delete import IMAGE_DELETE, parse_mode, permanent_delete_supported
data, error = await self._read_maintenance_body(request, ("token", "mode"))
if error is not None:
@@ -531,7 +531,12 @@ class MaintenanceRoutesMixin:
if plan.operation == IMAGE_DELETE:
mode = parse_mode(data.get("mode"))
if mode is None:
return _invalid('mode must be "library" or "trash"')
return _invalid('mode must be "library", "trash" or "permanent"')
if mode == "permanent" and not permanent_delete_supported():
# The review never offers it here; refuse a direct call (#644).
return _invalid(
"Permanent delete is only available on Linux and BSD servers"
)
elif "mode" in data:
return _invalid("Unknown field: mode")
store = self._maintenance_plans
+1 -1
View File
@@ -1,7 +1,7 @@
[project]
name = "promptmanager"
description = "A powerful ComfyUI custom node that extends the standard text encoder with persistent prompt storage, advanced search capabilities, and an automatic image gallery system using SQLite."
version = "3.6.0"
version = "3.7.0"
license = {file = "LICENSE"}
requires-python = ">=3.12"
dependencies = ["watchdog>=2.1.0", "Pillow>=10.1.0"]
+23 -2
View File
@@ -428,10 +428,31 @@ class TestPermanentMode(ImageDeleteTestCase):
else:
self.assertFalse(plan.get("permanent_delete_supported"))
async def test_permanent_is_refused_where_the_review_does_not_offer_it(self):
"""#644: without the Freedesktop backend the apply answers 400 for
"permanent" before any backup, and the file and its records stay."""
from utils import trash
fake_trash.uninstall()
self.addCleanup(fake_trash.uninstall)
self.write("a.png", b"aaa", mtime=1_000_000)
self.link("a.png")
with patch.object(trash, "BACKEND", trash.UnavailableBackend()):
plan = await self.review(["a.png"])
self.assertFalse(plan["permanent_delete_supported"])
with patch("os.remove") as remove:
body = await self.post(
APPLY, {"token": plan["token"], "mode": "permanent"}, 400
)
remove.assert_not_called()
self.assertIn("Linux", body["error"])
self.assertTrue((self.output_dir / "a.png").exists())
self.assertEqual(self.count("SELECT COUNT(*) FROM generated_images"), 1)
async def test_permanent_delete_removes_the_file(self):
fake_trash.uninstall()
self.addCleanup(fake_trash.uninstall)
if sys.platform == "win32":
if not image_delete.permanent_delete_supported():
self.skipTest("permanent delete is Linux/BSD only")
self.write("a.png", b"aaa", mtime=1_000_000)
self.link("a.png")
@@ -453,7 +474,7 @@ class TestPermanentMode(ImageDeleteTestCase):
fake_trash.uninstall()
self.addCleanup(fake_trash.uninstall)
if sys.platform == "win32":
if not image_delete.permanent_delete_supported():
self.skipTest("permanent delete is Linux/BSD only")
self.write("a.png", b"aaa", mtime=1_000_000)
self.link("a.png")