mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2026-03-11 00:00:01 +00:00
Decouple orphan pruning from asset seeding
- Remove automatic pruning from scan loop to prevent partial scans from deleting assets belonging to other roots - Add get_all_known_prefixes() helper to get prefixes for all root types - Add prune_orphans() method to AssetSeeder for explicit pruning - Add prune_first parameter to start() for optional pre-scan pruning - Add POST /api/assets/prune endpoint for explicit pruning via API - Update main.py startup to use prune_first=True for full startup scans - Add tests for new prune_orphans functionality Fixes issue where a models-only scan would delete all input/output assets. Amp-Thread-ID: https://ampcode.com/threads/T-019c2ba0-e004-7229-81bf-452b2f7f57a1 Co-authored-by: Amp <amp@ampcode.com>
This commit is contained in:
@@ -695,3 +695,23 @@ async def cancel_seed(request: web.Request) -> web.Response:
|
||||
if cancelled:
|
||||
return web.json_response({"status": "cancelling"}, status=200)
|
||||
return web.json_response({"status": "idle"}, status=200)
|
||||
|
||||
|
||||
@ROUTES.post("/api/assets/prune")
|
||||
async def prune_orphans(request: web.Request) -> web.Response:
|
||||
"""Prune orphaned assets that no longer exist on the filesystem.
|
||||
|
||||
This removes assets whose cache states point to files outside all known
|
||||
root prefixes (models, input, output).
|
||||
|
||||
Returns:
|
||||
200 OK with count of pruned assets
|
||||
409 Conflict if a scan is currently running
|
||||
"""
|
||||
pruned = asset_seeder.prune_orphans()
|
||||
if pruned == 0 and asset_seeder.get_status().state.value != "IDLE":
|
||||
return web.json_response(
|
||||
{"status": "scan_running", "pruned": 0},
|
||||
status=409,
|
||||
)
|
||||
return web.json_response({"status": "completed", "pruned": pruned}, status=200)
|
||||
|
||||
Reference in New Issue
Block a user