mirror of
https://git.sr.ht/~cismonx/bookmarkfs
synced 2025-06-07 19:58:50 +00:00
backend_firefox: improve bookmark storage init
- Check schema version when initializing database. - Minor refactor for db_check().
This commit is contained in:
parent
df29392008
commit
4f8b15fd80
2 changed files with 18 additions and 3 deletions
|
@ -2728,6 +2728,22 @@ store_init (
|
|||
) {
|
||||
int status = -EIO;
|
||||
|
||||
int64_t user_version;
|
||||
if (1 != db_exec(db, SQL_PRAGMA("user_version"), NULL, &user_version)) {
|
||||
return status;
|
||||
}
|
||||
// The oldest schema version supported by modern Firefox is 52,
|
||||
// which was used in Firefox 62-68. Fortunately, it has not changed
|
||||
// in a way that makes it incompatible with this backend.
|
||||
//
|
||||
// Schema version 78 is the latest version, used since Firefox 132.
|
||||
// Bump this version whenever a new schema version is available
|
||||
// (after ensuring that no incompatible changes are made).
|
||||
if (user_version < 52 || user_version > 78) {
|
||||
log_printf("unsupported schema version %" PRIi64, user_version);
|
||||
return status;
|
||||
}
|
||||
|
||||
char const *sql = "SELECT `id` FROM `moz_bookmarks` WHERE `guid` = ?";
|
||||
sqlite3_stmt *stmt = db_prepare(db, sql, strlen(sql), false);
|
||||
if (unlikely(stmt == NULL)) {
|
||||
|
|
5
src/db.c
5
src/db.c
|
@ -114,10 +114,9 @@ db_check (
|
|||
|
||||
int status = 0;
|
||||
ssize_t nrows = db_query(stmt, NULL, 0, false, db_check_cb, &status);
|
||||
if (nrows < 0) {
|
||||
return nrows;
|
||||
if (nrows != 1) {
|
||||
return -1;
|
||||
}
|
||||
xassert(nrows == 1);
|
||||
return status;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue