Skip to content

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

refactor(storage): extract profile module storage capture into helper

Steven Enamakeld2573dcad68e
diff --git a/crates/openhuman-core/src/modules/storage_import_support.rs b/crates/openhuman-core/src/modules/storage_import_support.rs
index adffe3da41..f392b03e1b 100644
--- a/crates/openhuman-core/src/modules/storage_import_support.rs
+++ b/crates/openhuman-core/src/modules/storage_import_support.rs
@@ -52,10 +52,26 @@ fn capture_module_storage(
.ok_or_else(|| anyhow!("profile import has no active profile host"))?;
let id = crate::profiles::ProfileId::parse(&profile_id)
.map_err(|error| anyhow!("invalid caller profile id: {error}"))?;
+ Ok(Some(capture_profile_module_storage(
+ &host,
+ &id,
+ &profile_id,
+ &caller_context,
+ scope,
+ )?))
+}
+
+fn capture_profile_module_storage(
+ host: &crate::profiles::ProfileHost,
+ id: &crate::profiles::ProfileId,
+ profile_id: &str,
+ caller_context: &Arc<crate::core::runtime::CoreContext>,
+ scope: crate::storage::Scope,
+) -> Result<CapturedModuleStorage> {
let profile = host
- .get(&id)
+ .get(id)
.ok_or_else(|| anyhow!("caller profile is no longer open"))?;
- require_profile_context(profile.context(), &caller_context, &profile_id)?;
+ require_profile_context(profile.context(), caller_context, profile_id)?;
let backend = host
.storage_backend_for(&profile)
.map_err(|error| {
@@ -65,11 +81,11 @@ fn capture_module_storage(
)
})?
.ok_or_else(|| anyhow!("profile storage is unavailable for this import"))?;
- Ok(Some(CapturedModuleStorage {
+ Ok(CapturedModuleStorage {
backend,
scope,
_profile: Some(profile),
- }))
+ })
}
/// Rejects work from an old context after a profile has been reopened under a