Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

fix(storage): use read-only connection for layout db operations

Steven Enamakelc600934b4145
diff --git a/crates/openhuman-core/src/storage/import/layout_db.rs b/crates/openhuman-core/src/storage/import/layout_db.rs
index a8aa372be7..600ace6612 100644
--- a/crates/openhuman-core/src/storage/import/layout_db.rs
+++ b/crates/openhuman-core/src/storage/import/layout_db.rs
@@ -35,7 +35,7 @@ fn sql(error: rusqlite::Error) -> LayoutError {
///
/// When the file cannot be opened or read.
pub fn table_counts(path: &Path) -> Result<Counts, LayoutError> {
- let conn = Connection::open_with_flags(path, OpenFlags::SQLITE_OPEN_READ_WRITE).map_err(sql)?;
+ let conn = Connection::open_with_flags(path, OpenFlags::SQLITE_OPEN_READ_ONLY).map_err(sql)?;
counts_of(&conn)
}
@@ -97,7 +97,7 @@ pub(crate) fn mismatch(source: &Counts, copy: &Counts) -> Option<String> {
/// an I/O or SQLite error. The source is untouched either way.
pub fn copy(source: &Path, dest: &Path) -> Result<DbCopy, LayoutError> {
let conn =
- Connection::open_with_flags(source, OpenFlags::SQLITE_OPEN_READ_WRITE).map_err(sql)?;
+ Connection::open_with_flags(source, OpenFlags::SQLITE_OPEN_READ_ONLY).map_err(sql)?;
let source_counts = counts_of(&conn)?;
if dest.is_file() {
if let Ok(existing) = table_counts(dest) {
@@ -158,7 +158,3 @@ pub fn checkpoint(path: &Path) -> Result<(), LayoutError> {
#[cfg(test)]
#[path = "layout_db_tests.rs"]
mod tests;
-
-#[cfg(test)]
-#[path = "layout_db_tests.rs"]
-mod tests;