Skip to content

Clean up unique browser partitions on delete + drive-aware data defaults#1016

Open
Kosinkadink wants to merge 5 commits into
mainfrom
feat/delete-partition-cleanup-and-drive-aware-defaults
Open

Clean up unique browser partitions on delete + drive-aware data defaults#1016
Kosinkadink wants to merge 5 commits into
mainfrom
feat/delete-partition-cleanup-and-drive-aware-defaults

Conversation

@Kosinkadink

@Kosinkadink Kosinkadink commented Jun 9, 2026

Copy link
Copy Markdown
Member

Closes #1017

Summary

Two related disk/storage fixes for the launcher.

1. Browser partitions no longer leak on delete

Deleting an install previously only removed the install dir and the installations.json record. Unique-partition installs (browserPartition: 'unique') each own a persist:<id> bucket under userData/Partitions/<id> (cookies, IndexedDB, localStorage, service-worker cache, GPUCache). The id is unique per-install and never reused, so every create-unique -> delete cycle stranded one of these folders forever. (Copies were already safe: each copy gets a fresh id and its own deep-copied partition.)

handleDelete now, on both delete paths:

  1. removes the install record first (so the user-visible delete is deterministic), then
  2. best-effort cleans the partition - clears the session (clearStorageData, raced against a 5s timeout so it can never hang the operation or hold its lock) and removes Partitions/<id> (force + transient-lock retries).

Shared-partition installs are a no-op (they all share persist:shared, which must never be deleted). Worst case degrades to the old behavior (one folder left behind) - never a lock-up.

2. Large data dirs default to a sensible, grouped location

Previously the multi-GB consumers defaulted to the system drive even when the app was installed elsewhere, and on the common system-drive install they landed in poor spots: the install root and shared models/input/output under the home root, and the download cache under roaming AppData (which bloats roaming/AD profiles on login sync). These are still only defaults - users can override each in Settings.

Non-system-drive installs (e.g. app installed to D:) now group everything under a single <drive>\Comfy-Desktop parent instead of scattering at the drive root:

  • <drive>\Comfy-Desktop\ComfyUI-Installs
  • <drive>\Comfy-Desktop\ComfyUI-Shared (models / input / output)
  • <drive>\Comfy-Desktop\ComfyUI-Cache\download-cache

System-drive Windows installs now distinguish new vs existing users:

  • New installs group under %LOCALAPPDATA%\Comfy-Desktop (the standard per-user, non-roaming spot for large app data — and writable without admin, unlike a drive root):
    • %LOCALAPPDATA%\Comfy-Desktop\ComfyUI-Installs
    • %LOCALAPPDATA%\Comfy-Desktop\ComfyUI-Shared (models / input / output)
    • %LOCALAPPDATA%\Comfy-Desktop\ComfyUI-Cache\download-cache
  • Existing installs keep their original home-root + roaming-cache layout — no data is moved or migrated.

New vs existing is classified from a home-root footprint (~/ComfyUI-Installs / ~/ComfyUI-Shared) and then pinned with a one-time marker (userData/data-location.json) so a user's chosen location can never flip on a later launch (e.g. if the legacy folders appear externally). The marker is written once at startup, never at module import. settings.json existence is deliberately not used as the signal (a new user creates it on first run).

Non-Windows behavior and the small Electron-managed userData state are unchanged (the latter intentionally stays on the system drive).

Changes

  • src/main/lib/ipc/shared.ts - add deleteBrowserPartition (timeout-bounded session clear + dir removal).
  • src/main/lib/ipc/sessionActions/delete.ts - call it on both delete paths, after record removal.
  • src/main/lib/paths.ts - add selectedInstallDrive / defaultDataRoot / defaultDownloadCacheDir; system-drive Windows classifier (%LOCALAPPDATA%\Comfy-Desktop for new installs, home for existing) with a pinned marker via persistWinDataRootChoice; builtinDefaultInstallDir uses the data root.
  • src/main/index.ts - call persistWinDataRootChoice() once at startup.
  • src/main/settings.ts - default installDir, shared root, and download cache to the data root.

Tests

  • delete.integration.test.ts - unique partition removed + session cleared; shared partition untouched; delete still completes when clearStorageData rejects; cleanup works when the install dir is already gone.
  • paths.test.ts - drive redirect to <drive>\Comfy-Desktop on win32 non-home drive; system-drive new install -> %LOCALAPPDATA%\Comfy-Desktop; existing install (home footprint) -> home root + roaming cache; marker overrides later footprint changes in both directions; persistWinDataRootChoice writes the classified mode once and never overwrites; non-Windows unchanged.
  • Full suite green: typecheck, lint, test (2053), integration (21), build.

Kosinkadink and others added 2 commits June 9, 2026 06:07
Deleting an install never removed its browser partition. Unique-partition
installs each own a persist:<id> bucket under userData/Partitions/<id> that
nothing else reuses, so every delete leaked one forever. handleDelete now
removes the install record first, then best-effort clears the session
(timeout-bounded) and deletes the partition dir (force + retries) so it can
never hang or lock up the delete. Shared partitions are left untouched.

Also make the large data dirs follow the drive the user picks in the Windows
installer: when the app is installed to a non-system drive, installDir, the
shared models/input/output root, and the download cache default to that drive
instead of always landing on the system drive. Non-Windows and same-drive
installs keep the existing home/userData defaults.

Amp-Thread-ID: https://ampcode.com/threads/T-019eac5b-d0b9-7090-a4dd-491a74ab1fbe
Co-authored-by: Amp <amp@ampcode.com>
When the app is installed to a non-system drive, installs, shared
models/input/output, and the download cache now live under one
<drive>\\Comfy-Desktop parent instead of three separate folders at the
drive root. Home-dir and non-Windows defaults are unchanged.

Amp-Thread-ID: https://ampcode.com/threads/T-019eac5b-d0b9-7090-a4dd-491a74ab1fbe
Co-authored-by: Amp <amp@ampcode.com>
@Kosinkadink

Copy link
Copy Markdown
Member Author

Follow up - see if we can get the electron-manager userData moved as well.

Kosinkadink and others added 3 commits June 9, 2026 17:04
…-cleanup-and-drive-aware-defaults

Amp-Thread-ID: https://ampcode.com/threads/T-019eac5b-d0b9-7090-a4dd-491a74ab1fbe
Co-authored-by: Amp <amp@ampcode.com>

# Conflicts:
#	src/main/lib/ipc/sessionActions/delete.ts
…system drive

On a system-drive Windows install, the large data dirs (installs, shared
models/input/output, download cache) previously defaulted to the user home
root and the cache to roaming AppData. New installs now group under
%LOCALAPPDATA%\Comfy-Desktop instead, while existing installs keep their
home-root layout. The choice is classified from a home-root footprint and
pinned with a one-time marker so it never flips between launches.

Amp-Thread-ID: https://ampcode.com/threads/T-019eac3f-cda6-74ea-ba76-49da53cadea2
Co-authored-by: Amp <amp@ampcode.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Disk usage: orphaned browser partitions on delete + data dirs always default to system drive

1 participant