Skip to content

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

refactor(security): split device store into documents and import modules

Steven Enamakel75e789e086a1
diff --git a/crates/openhuman-core/src/security/devices/store_documents.rs b/crates/openhuman-core/src/security/devices/store_documents.rs
index 60ba2092bd..ce1c2717ff 100644
--- a/crates/openhuman-core/src/security/devices/store_documents.rs
+++ b/crates/openhuman-core/src/security/devices/store_documents.rs
@@ -52,8 +52,9 @@ pub(super) fn current(config: &Config) -> Result<Docs> {
/// The channel id a document id was built from (ids are `Key::of` of it).
fn channel_id_of(id: &str) -> String {
- tinystoragedrivers::Key::from_stored(id)
- .split()
+ tinystoragedrivers::Key::new(id)
+ .ok()
+ .and_then(|key| key.split())
.and_then(|mut parts| (parts.len() == 1).then(|| parts.remove(0)))
.unwrap_or_else(|| id.to_string())
}
diff --git a/crates/openhuman-core/src/security/devices/store_import.rs b/crates/openhuman-core/src/security/devices/store_import.rs
index b903ceb407..adaae4e9f6 100644
--- a/crates/openhuman-core/src/security/devices/store_import.rs
+++ b/crates/openhuman-core/src/security/devices/store_import.rs
@@ -10,7 +10,7 @@ use anyhow::{Context, Result};
use rusqlite::Connection;
use serde_json::{json, Value};
-use super::store_documents::DEVICES;
+use super::storage_schema::LEGACY_DEVICES;
use crate::config::Config;
use crate::storage::import::{table_exists, ImportDoc};
@@ -68,7 +68,7 @@ fn read_rows(conn: &Connection) -> Result<Vec<ImportDoc>> {
let rows = stmt
.query_map([], |row| {
Ok(ImportDoc {
- collection: DEVICES,
+ collection: LEGACY_DEVICES,
id: row.get(0)?,
doc: json!({
"label": row.get::<_, String>(1)?,