Skip to content

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

chore: files changed crates/openhuman-core/src/config/schema/load/branches.rs

Steven Enamakel895a06363043
diff --git a/crates/openhuman-core/src/config/schema/load/branches.rs b/crates/openhuman-core/src/config/schema/load/branches.rs
index fccf0fc8eb..d08d6b1aaf 100644
--- a/crates/openhuman-core/src/config/schema/load/branches.rs
+++ b/crates/openhuman-core/src/config/schema/load/branches.rs
@@ -190,7 +190,7 @@ impl Config {
"[config] Config file already renamed by read recovery; \
persisting recovered config"
);
- if let Err(e) = config.save().await {
+ if let Err(e) = Box::pin(save_recovered(&config, source.as_ref())).await {
tracing::warn!(
path = %config.config_path.display(),
error = %e,
@@ -206,7 +206,7 @@ impl Config {
dst = %corrupted_path.display(),
"[config] Renamed corrupted config; persisting recovered config"
);
- if let Err(e) = config.save().await {
+ if let Err(e) = Box::pin(save_recovered(&config, source.as_ref())).await {
tracing::warn!(
path = %config.config_path.display(),
error = %e,
@@ -293,3 +293,20 @@ impl Config {
Ok(*config)
}
}
+
+/// Persist a config the loader recovered from corruption.
+///
+/// On a document source this can only be the file fallback (a scope with no
+/// document yet: a document body is parsed strictly and never "recovered"),
+/// and the corrupt `config.toml` has been renamed aside. The document save
+/// strips the bootstrap tables and never writes the file, so the file is
+/// rewritten too: otherwise a storage URL that lived only in its `[storage]`
+/// table would be gone on the next boot.
+async fn save_recovered(config: &Config, source: &dyn super::source::ConfigSource) -> Result<()> {
+ config.save().await?;
+ if source.label() == "document" {
+ let file = super::source::FileConfigSource::new(&config.config_path);
+ Box::pin(config.save_to(&file)).await?;
+ }
+ Ok(())
+}