core/database: Autosave databases if the file version changes

To make sure the latest changes are recorded to disk.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This commit is contained in:
Anna Schumaker 2016-09-26 11:58:58 -04:00
parent 93d1550763
commit cf4eedb592
2 changed files with 6 additions and 0 deletions

View File

@ -1,6 +1,7 @@
6.5.0:
- Add a switch to disable GUI tests
- Don't save and restore the "Last Played" tracks column width
- Save databases if they have been upgraded
6.5.0-rc:
- Convert to CMake/CTest

View File

@ -113,6 +113,7 @@ void db_autosave(struct database *db)
void db_load(struct database *db)
{
unsigned int size;
bool save;
if (file_open(&db->db_file, OPEN_READ) == false)
return;
@ -124,7 +125,11 @@ void db_load(struct database *db)
__dbe_setup(db, i);
}
save = file_version(&db->db_file) != OCARINA_MINOR_VERSION;
file_close(&db->db_file);
if (save)
db_autosave(db);
}
struct db_entry *db_insert(struct database *db, const gchar *key)