The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
refactor(storage): update tinyjuice savings import logic
Steven Enamakelbf35264f8c75
diff --git a/crates/openhuman-core/src/modules/storage_import_tinyjuice_savings.rs b/crates/openhuman-core/src/modules/storage_import_tinyjuice_savings.rsindex a889f7762e..a4a6197fb5 100644--- a/crates/openhuman-core/src/modules/storage_import_tinyjuice_savings.rs+++ b/crates/openhuman-core/src/modules/storage_import_tinyjuice_savings.rs@@ -61,13 +61,33 @@ pub(crate) async fn import_legacy<F, Fut>(adopt: F,) -> Result<Outcome>where- F: FnOnce(SavingsAggregate) -> Fut,- Fut: Future<Output = Result<bool>>,+ F: FnOnce(SavingsAggregate) -> Fut + Send + 'static,+ Fut: Future<Output = Result<bool>> + Send + 'static,{- let Some(scoped) = support::module_scope(ctx, MODULE_ID)? else {+ if std::fs::symlink_metadata(file).is_err() {+ return Ok(Outcome::NoSource);+ }+ let marker = support::marker_id("savings", file);+ let file = file.to_owned();+ let ctx_for_read = ctx.clone();+ let result = support::with_module_claim(+ ctx,+ MODULE_ID,+ MARKER_KIND,+ &marker,+ move |scoped| {+ crate::storage::block_on_anyhow(async move {+ import_into(&ctx_for_read, &scoped, &file, adopt).await+ })+ },+ )?;+ let Some(result) = result else {return Ok(Outcome::NoBackend);};- import_into(&scoped, file, adopt).await+ Ok(match result {+ support::ClaimedImport::AlreadyDone => Outcome::AlreadyDone,+ support::ClaimedImport::Imported(outcome) => outcome,+ })}async fn import_into<F, Fut>(scoped: &Storage, file: &Path, adopt: F) -> Result<Outcome>@@ -75,10 +95,6 @@ whereF: FnOnce(SavingsAggregate) -> Fut,Fut: Future<Output = Result<bool>>,{- let marker = support::marker_id("savings", file);- if support::already_imported(scoped, MARKER_KIND, &marker).await? {- return Ok(Outcome::AlreadyDone);- }if std::fs::symlink_metadata(file).is_err() {return Ok(Outcome::NoSource);}@@ -102,7 +118,6 @@ wherefalse}};- support::mark_imported(scoped, MARKER_KIND, &marker).await?;log::debug!("{LOG_PREFIX} adopted={adopted}");Ok(Outcome::Imported { adopted })}