Skip to content

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

feat(storage_import): add backend check to legacy import functions

Steven Enamakel91aed6160d11
diff --git a/crates/openhuman-core/src/modules/storage_import_tinybox.rs b/crates/openhuman-core/src/modules/storage_import_tinybox.rs
index bd29a4af7d..7807531d28 100644
--- a/crates/openhuman-core/src/modules/storage_import_tinybox.rs
+++ b/crates/openhuman-core/src/modules/storage_import_tinybox.rs
@@ -53,6 +53,9 @@ pub(crate) enum Outcome {
/// Imports the index under `<workspace_dir>/jails` into the module's scope of
/// the installed backend.
pub(crate) async fn import_legacy(ctx: &DispatchCtx, workspace_dir: &Path) -> Result<Outcome> {
+ if support::module_scope(ctx, MODULE_ID)?.is_none() {
+ return Ok(Outcome::NoBackend);
+ }
let base = workspace_dir.join(BASE_DIR);
let index = base.join(INDEX_FILE);
if !index.is_file() {
diff --git a/crates/openhuman-core/src/modules/storage_import_tinyconnectors.rs b/crates/openhuman-core/src/modules/storage_import_tinyconnectors.rs
index b89b97159b..858f543896 100644
--- a/crates/openhuman-core/src/modules/storage_import_tinyconnectors.rs
+++ b/crates/openhuman-core/src/modules/storage_import_tinyconnectors.rs
@@ -62,6 +62,9 @@ pub(crate) enum Outcome {
/// Imports the legacy files under `state_dir` into the module's scope of the
/// installed backend.
pub(crate) async fn import_legacy(ctx: &DispatchCtx, state_dir: &Path) -> Result<Outcome> {
+ if support::module_scope(ctx, MODULE_ID)?.is_none() {
+ return Ok(Outcome::NoBackend);
+ }
let prefs_dir = state_dir.join(PREFS_DIR);
let triggers_dir = state_dir.join(TRIGGERS_DIR);
if !prefs_dir.is_dir() && !triggers_dir.is_dir() {
diff --git a/crates/openhuman-core/src/modules/storage_import_tinyjuice_savings.rs b/crates/openhuman-core/src/modules/storage_import_tinyjuice_savings.rs
index 5a63d53501..f4be51daab 100644
--- a/crates/openhuman-core/src/modules/storage_import_tinyjuice_savings.rs
+++ b/crates/openhuman-core/src/modules/storage_import_tinyjuice_savings.rs
@@ -64,6 +64,9 @@ where
F: FnOnce(SavingsAggregate) -> Fut + Send + 'static,
Fut: Future<Output = Result<bool>> + Send + 'static,
{
+ if support::module_scope(ctx, MODULE_ID)?.is_none() {
+ return Ok(Outcome::NoBackend);
+ }
if std::fs::symlink_metadata(file).is_err() {
return Ok(Outcome::NoSource);
}
diff --git a/crates/openhuman-core/src/modules/storage_import_tinywallet.rs b/crates/openhuman-core/src/modules/storage_import_tinywallet.rs
index a4637ceb36..37074e680a 100644
--- a/crates/openhuman-core/src/modules/storage_import_tinywallet.rs
+++ b/crates/openhuman-core/src/modules/storage_import_tinywallet.rs
@@ -50,6 +50,9 @@ pub(crate) enum Outcome {
/// Imports the legacy ledger under `workspace_dir` into the module's scope of
/// the installed backend.
pub(crate) async fn import_legacy(ctx: &DispatchCtx, workspace_dir: &Path) -> Result<Outcome> {
+ if support::module_scope(ctx, MODULE_ID)?.is_none() {
+ return Ok(Outcome::NoBackend);
+ }
let ledger = workspace_dir.join(LEDGER_FILE);
if !ledger.is_file() {
return Ok(Outcome::NoSource);