From cf4eedb592ca25db88d0b46116372fac490453d8 Mon Sep 17 00:00:00 2001 From: Anna Schumaker Date: Mon, 26 Sep 2016 11:58:58 -0400 Subject: [PATCH] core/database: Autosave databases if the file version changes To make sure the latest changes are recorded to disk. Signed-off-by: Anna Schumaker --- CHANGELOG | 1 + core/database.c | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index 54e3fd69..08c12a1e 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -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 diff --git a/core/database.c b/core/database.c index 162edb4d..3bf8839f 100644 --- a/core/database.c +++ b/core/database.c @@ -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)