#77 closed enhancement (fixed)
maintain database backups
| Reported by: | simon | Owned by: | dstillman |
|---|---|---|---|
| Priority: | critical | Milestone: | 1.0 Beta 1 |
| Component: | data layer | Version: | 1.0 |
| Keywords: | Cc: | simon |
Description
unfortunately, it seems like SQLite databases are easily corrupted. today, i got the following error:
scholar(2): [Exception... "Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [mozIStorageStatement.execute]" nsresult: "0x80004005 (NS_ERROR_FAILURE)" location: "JS frame :: chrome://scholar/content/xpcom/db.js :: query :: line 75" data: no] [QUERY: INSERT INTO items (itemTypeID,title) VALUES (?,?)] [ERROR: database disk image is malformed]
while not a big deal for me, if people are storing all their notes and bibliographic information in Scholar for Firefox, we should make sure it doesn't get lost.
Change History (3)
comment:1 Changed 10 years ago by dstillman
- Cc simon added
- Status changed from new to assigned
comment:2 Changed 10 years ago by dstillman
- Resolution set to fixed
- Status changed from assigned to closed
(In [406]) Closes #77, maintain database backups
The Scholar database is backed up on browser close. On startup, if the main database is damaged, the extension saves a copy of the damaged file and tries to restore from the last automatic backup. If it fails, it creates a new database file.
New methods:
Scholar.getScholarDatabase(string [ext])
Scholar.backupDatabase()
Scholar.moveToUnique(file, newFile) -- find a unique filename using the leafName of newFile as the suggested name (using the built-in Mozilla functionality) and move the file there
Scholar.Date.getFileDateString(file)
Scholar.Date.getFileTimeString(file)
comment:3 Changed 10 years ago by dstillman
(In [407]) Addresses #77, maintain database backups
Temporarily added in a check of the backup file on startup, since I'm not entirely convinced that the backup mechanism on shutdown couldn't create a corrupt file under certain conditions
If you run with debug output on and notice the "Backup file was corrupt" message, let me know.
As I discussed with Simon, this may have been from him writing to the DB from the sqlite CLI while the browser was writing. As far as I know we're only accessing the DB from the main thread (the connection object is private to the DB class), which I think should prevent problems otherwise, though it's possible there are still some issues. See How to corrupt your database on the mozStorage page for more details.
Nonetheless, we definitely need an automatic internal backup system in addition to any external backup functionality we provide to the user.