Skip to content

Fix default database path for custom user directory#14539

Open
Constantine1916 wants to merge 1 commit into
Comfy-Org:masterfrom
Constantine1916:fix/database-user-directory
Open

Fix default database path for custom user directory#14539
Constantine1916 wants to merge 1 commit into
Comfy-Org:masterfrom
Constantine1916:fix/database-user-directory

Conversation

@Constantine1916

Copy link
Copy Markdown

Fixes #14524

Summary

  • Resolve the default SQLite database URL from the effective user directory instead of the install directory.
  • Preserve explicit --database-url behavior and keep comfy.cli_args.args.database_url populated for compatibility.
  • Copy the legacy default database into the effective user directory when the target database does not exist, leaving the legacy file untouched.

Notes

For users who did not explicitly pass --database-url and use --user-directory or --base-directory, the default DB location now follows the effective user directory. If an existing legacy install-directory user/comfyui.db is present and the new target DB is missing, it is copied once to avoid appearing to lose existing asset data.

Testing

  • .venv/bin/python -m pytest tests-unit/app_test/test_migrations.py tests-unit/app_test/database_path_test.py -q
  • .venv/bin/python -m ruff check .

@coderabbitai

coderabbitai Bot commented Jun 18, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 757d039d-3a00-4dee-9cd1-462a80c84b8b

📥 Commits

Reviewing files that changed from the base of the PR and between 16514da and 374bb9a.

📒 Files selected for processing (3)
  • app/database/db.py
  • comfy/cli_args.py
  • tests-unit/app_test/database_path_test.py

📝 Walkthrough

Walkthrough

comfy/cli_args.py gains a sys import and post-parse logic that inspects sys.argv to set args.database_url_explicit, indicating whether --database-url was provided on the command line. app/database/db.py adds four helper functions: get_database_url() (resolves the effective SQLite URL respecting the explicit flag), get_legacy_default_db_path() (derives the legacy comfyui.db path), copy_legacy_default_db() (copies the legacy DB to the target path when it does not already exist), and prepare_file_db_path() (creates the destination directory and triggers the legacy copy). init_db() and _init_file_db() are updated to use these helpers. Six new unit tests cover URL resolution and legacy DB copy behavior.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 13.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: resolving the default database path to respect custom user directory arguments instead of ignoring them.
Description check ✅ Passed The description is well-related to the changeset, explaining the fix, noting compatibility preservation, and documenting the legacy database copying behavior.
Linked Issues check ✅ Passed The PR fulfills all coding requirements from issue #14524: it resolves the database path from the effective user directory, preserves explicit --database-url behavior, and implements legacy database copying to prevent data loss.
Out of Scope Changes check ✅ Passed All changes are scoped to the three files modified and directly support the issue requirements: database path resolution, explicit URL detection, and legacy database migration.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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.

user-directory and base-directory args being ignored in DB setup

2 participants