Kunzisoft / KeePassDX

Lightweight vault and password manager for Android, KeePassDX allows editing encrypted data in a single file in KeePass format and fill in the forms in a secure way.
https://www.keepassdx.com/
GNU General Public License v3.0
4.29k stars 260 forks source link

Automatically opening Updated Nextcloud database #1693

Open alexknop opened 7 months ago

alexknop commented 7 months ago

Describe the bug When using a Nextcloud-stored Keepass database as the primary database, after it is updated (either in KeepassDX itself or on another device and then Nextcloud syncs the updated file), KeepassDX will try to automatically reopen this file, but its references are outdated and there are file errors. Going back to the database list and reselecting this same database goes to a normal, error-free Login screen which works.

To Reproduce

Steps to reproduce the behavior:

  1. Select a Nextcloud-stored Keepass database file and Log in to the database so it is remembered
  2. Add/edit an entry and save database. Nextcloud client will sync the file
  3. Close KeepassDX and re-open.
  4. KeepassDX will try to reopen the database but will have errors and you cannot Login

Expected behavior No errors

KeePass Database

KeePassDX:

Android:

Additional context This is how I select a database Screenshot_2023-11-12-11-42-10-719 Just a snippet showing the URI Screenshot_2023-11-12-11-42-39-917 This is the error I get and I cannot login. Top row doesn't look normal either. Usually it shows the name of the database. Screenshot_2023-11-12-12-12-48-980 However from here I can go back and reselect the Database and then the next page works normally Screenshot_2023-11-12-12-32-30-695 Screenshot_2023-11-12-12-32-36-571

J-Jamet commented 7 months ago

This happens because the file provider contract simply returns an error when calling the URI, as the file is not correctly initialized by the file manager at this moment. After a next call to the URI, this time the file provider has succeeded in retrieving the file.

But it's not up to KeePassDX to check that the URI points to a file that's still available constantly, as DocumentsFile's methods are synchronous.

The only improvement I can suggest is to add a button to force the URI to be reloaded, which would have the same effect as doing the back and reselecting the base.