keepassxc icon indicating copy to clipboard operation
keepassxc copied to clipboard

Don't auto close database unlock dialog when underlying file is unavailable

Open Copilot opened this issue 8 months ago • 1 comments

This PR addresses the issue where KeePassXC would automatically close the database unlock dialog when the underlying database file is temporarily unavailable, preventing users from retrying once the file becomes accessible.

Problem

When KeePassXC starts automatically on user login and tries to open the most recently used database file, if that file is stored on cloud storage (like Google Drive) that hasn't finished mounting yet, the unlock dialog would never appear. This creates a race condition where users have to manually reselect their database file after the cloud storage becomes available.

Solution

The fix implements the suggestion from @droidmonkey to keep the unlock dialog open even when the file is missing, allowing users to retry when the file becomes available.

Key Changes

DatabaseTabWidget.cpp:

  • Removed early return when canonicalFilePath.isEmpty() (indicating file doesn't exist)
  • Continue to show error message but proceed with creating the database tab
  • Allow unlock dialog to be displayed even when file is missing

DatabaseOpenWidget.cpp:

  • Added proper error handling when Database::open() fails during header reading
  • Show informative warning message when file is unavailable
  • Continue to display unlock dialog instead of failing silently

Test Coverage

Added testOpenMissingDatabaseFile() test to verify:

  • Database tab is created even when file doesn't exist
  • Unlock dialog remains open and functional
  • User can retry when file becomes available

User Experience

Before this fix:

  1. KeePassXC starts before cloud storage mounts
  2. Database file is unavailable
  3. No unlock dialog appears
  4. User must manually reopen the database

After this fix:

  1. KeePassXC starts before cloud storage mounts
  2. Database file is unavailable
  3. Unlock dialog appears with warning message
  4. User can retry unlock once file becomes available

This provides a much better user experience for cloud storage scenarios and other cases where files may be temporarily unavailable.

Fixes #9539.

[!WARNING]

Firewall rules blocked me from connecting to one or more addresses

I tried to connect to the following addresses, but was blocked by firewall rules:

  • 224.0.0.251
  • esm.ubuntu.com
    • Triggering command: /usr/lib/apt/methods/https (dns block)

If you need me to access, download, or install something from one of these locations, you can either:


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

Copilot avatar Jun 15 '25 17:06 Copilot

Codecov Report

:x: Patch coverage is 47.61905% with 11 lines in your changes missing coverage. Please review. :white_check_mark: Project coverage is 64.38%. Comparing base (72308a1) to head (66ff42c).

Files with missing lines Patch % Lines
src/gui/DatabaseOpenWidget.cpp 50.00% 5 Missing :warning:
src/gui/DatabaseTabWidget.cpp 50.00% 5 Missing :warning:
src/gui/MainWindow.cpp 0.00% 1 Missing :warning:
Additional details and impacted files
@@           Coverage Diff            @@
##           develop   #12200   +/-   ##
========================================
  Coverage    64.37%   64.38%           
========================================
  Files          378      378           
  Lines        39840    39850   +10     
========================================
+ Hits         25646    25654    +8     
- Misses       14194    14196    +2     

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

:rocket: New features to boost your workflow:
  • :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • :package: JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

codecov[bot] avatar Jun 15 '25 17:06 codecov[bot]

Will reimpmement at a later date

droidmonkey avatar Nov 23 '25 18:11 droidmonkey