replaysMike / Binner

Open source parts inventory system for makers, electronics hobby, and professional engineers
https://binner.io
GNU General Public License v3.0
261 stars 41 forks source link

[Bug]: Restore not working corectly #236

Closed jingsno closed 4 months ago

jingsno commented 1 year ago

Binner version

v.2.6.0

Operating System

Windows / Linux

Describe the bug and the steps to reproduce it

When trying to restore the database with the "restore function", the software states "Binner restored successfully!", but no inventory is restored. The "Your Overview" still shows zero inventory.

If I observe the filesystem during restore, I can see that the correct binner.db file is written to the filesystem, from the "binner-backup-xxxx-x-xx.bak" file. If restart the Binner service, the Inventory still shows zero parts.

I can also observe that when I stop the Binner service to restart, the binner.db file is replaced with a smaler (I presume empty) database file.

If i copy the extracted Binner.bak file from the backup file, into the correct directory, as "binner.db", when the service is stopped, the restore works fine, and the inventory is back.

I've observed this on both Windows, and the linux version.

Would you like to attach your appsetings.json configuration?

No response

Screenshots or Videos (Optional, but they help!)

No response

Are you able to contribute a PR? (No is ok!)

None

replaysMike commented 4 months ago

definitely something wrong here, looking into the issue.

replaysMike commented 4 months ago

I think I've figured out what's going on here. After restoring, the database file is copied to the configured location at C:\Binner\Binner.db. However, even though the backup database is copied overtop the existing one the SQLite driver seems to overwrite it immediately after restore. Restarting the service puts you back into the original database instead of the overwritten one. If I manually copy the db file while the service is not running all the data is restored.

This may have been some behavioral change with SQLite, as this used to work. I'll see if I can come up with a workaround.

replaysMike commented 4 months ago

Came up with a way to get SQLite to forcefully release the lock on the file. Fix is in v2.6.3