mirror of
https://github.com/pewdiepie-archdaemon/odysseus.git
synced 2026-06-16 17:55:26 -04:00
Admin: wipe gallery albums with images
The /api/admin/wipe/gallery branch deleted GalleryImage rows but left every GalleryAlbum row behind (GalleryAlbum wasn't even imported). After "wipe gallery" the user is left with orphaned, empty albums whose cover_id points at now-deleted images — inconsistent with the other wipe branches, which clear both parent and child tables. Delete GalleryAlbum alongside GalleryImage and include both in the returned count. Adds tests/test_admin_wipe_gallery.py: seeds a real in-memory SQLite DB with an album + image, runs the actual wipe handler, and asserts both tables are emptied. Fails before this change (albums survive).
This commit is contained in:
@@ -27,6 +27,7 @@ from core.database import (
|
||||
Document,
|
||||
DocumentVersion,
|
||||
GalleryImage,
|
||||
GalleryAlbum,
|
||||
CalendarEvent,
|
||||
CalendarCal,
|
||||
)
|
||||
@@ -145,8 +146,9 @@ def setup_admin_wipe_routes(session_manager):
|
||||
return {"status": "deleted", "kind": kind, "count": count}
|
||||
|
||||
if kind == "gallery":
|
||||
count = db.query(GalleryImage).count()
|
||||
count = db.query(GalleryImage).count() + db.query(GalleryAlbum).count()
|
||||
db.query(GalleryImage).delete()
|
||||
db.query(GalleryAlbum).delete()
|
||||
db.commit()
|
||||
# Also drop the upload dir so disk doesn't keep orphans.
|
||||
_rmtree_quiet(os.path.join(DATA_DIR, "gallery"))
|
||||
|
||||
Reference in New Issue
Block a user