Skip to content

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

refactor(storage): move legacy inventory reading to blocking thread

Steven Enamakelba3f4fc3763b
diff --git a/crates/openhuman-core/src/storage/scope_move.rs b/crates/openhuman-core/src/storage/scope_move.rs
index 080ac17527..d45b547b4b 100644
--- a/crates/openhuman-core/src/storage/scope_move.rs
+++ b/crates/openhuman-core/src/storage/scope_move.rs
@@ -303,7 +303,12 @@ pub async fn run_from_source(
source_db: &std::path::Path,
known: &Known,
) -> anyhow::Result<MoveReport> {
- let inventory = crate::storage::import::scope_move::LegacyScopeInventory::read(source_db)?;
+ let path = source_db.to_owned();
+ let inventory = tokio::task::spawn_blocking(move || {
+ crate::storage::import::scope_move::LegacyScopeInventory::read(&path)
+ })
+ .await
+ .context("join the legacy scope inventory reader")??;
copy_inventory(backend, known, &inventory).await
}
diff --git a/crates/openhuman-core/src/storage/scope_move_tests.rs b/crates/openhuman-core/src/storage/scope_move_tests.rs
index feee3cb604..882db0a5f2 100644
--- a/crates/openhuman-core/src/storage/scope_move_tests.rs
+++ b/crates/openhuman-core/src/storage/scope_move_tests.rs
@@ -63,6 +63,7 @@ async fn a_v1_scope_moves_its_documents_streams_and_blobs() {
let backend: Arc<dyn StorageBackend> = Arc::new(MemoryStorage::new());
let source = "alice~asha";
let inventory = crate::storage::import::scope_move::LegacyScopeInventory {
+ scopes: vec![source.into()],
documents: vec![crate::storage::import::scope_move::LegacyDocument {
scope: source.into(),
collection: "notes".into(),
@@ -131,6 +132,7 @@ async fn a_record_already_in_the_target_wins_a_merge() {
.await
.unwrap();
let inventory = crate::storage::import::scope_move::LegacyScopeInventory {
+ scopes: vec!["asha".into()],
documents: vec![crate::storage::import::scope_move::LegacyDocument {
scope: "asha".into(),
collection: "notes".into(),