snapshot: sqlite: use a subdirectory for consistency with LMDB
All checks were successful
ci/woodpecker/pr/debug Pipeline was successful

Currently, taking a snapshot of the metadata database with sqlite creates
a sqlite file without extension with the following format:

    snapshots/2025-01-26T15:29:17Z

This makes it hard to understand what kind of data this is, and is not
consistent with LMDB:

    snapshots/2025-01-26T15:29:17Z/data.mdb

With this change, we now get a directory with a single db.sqlite file:

    snapshots/2025-01-26T15:29:17Z/db.sqlite
This commit is contained in:
Baptiste Jonglez 2025-01-26 16:29:51 +01:00
parent efa6f3d85e
commit 43402c9619

View file

@ -144,9 +144,12 @@ impl IDb for SqliteDb {
let percent = (p.pagecount - p.remaining) * 100 / p.pagecount;
info!("Sqlite snapshot progress: {}%", percent);
}
std::fs::create_dir_all(to)?;
let mut path = to.clone();
path.push("db.sqlite");
self.db
.get()?
.backup(rusqlite::DatabaseName::Main, to, Some(progress))?;
.backup(rusqlite::DatabaseName::Main, path, Some(progress))?;
Ok(())
}