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(update): extract staged path logic into helper function
Steven Enamakelc7288f2c28f2
diff --git a/crates/openhuman-core/src/platform/update/core.rs b/crates/openhuman-core/src/platform/update/core.rsindex 59564381d9..bbbe09af06 100644--- a/crates/openhuman-core/src/platform/update/core.rs+++ b/crates/openhuman-core/src/platform/update/core.rs@@ -124,6 +124,14 @@ fn staged_binary_staging_name() -> &'static str {}}+fn staged_asset_path(dir: &std::path::Path, asset_name: &str, is_archive: bool) -> std::path::PathBuf {+ if is_archive || asset_name == staged_binary_name() {+ dir.join(staged_binary_staging_name())+ } else {+ dir.join(asset_name)+ }+}+/// Make `tmp` executable and move it onto `dest` atomically, cleaning up `tmp`/// if the rename fails.fn finalize_executable(tmp: &std::path::Path, dest: &std::path::Path) -> Result<(), String> {@@ -462,13 +470,8 @@ pub async fn download_and_stage_with_version(// An archive stages as the executable it contains, not as itself: marking a// `.tar.gz` 0755 and restarting into it cannot work (#6766).let is_archive = is_archive_asset(asset_name);- let staged_path = if is_archive {- // Keep the downloaded binary separate from the running executable;- // the restart flow owns installing/replacing it.- dir.join(staged_binary_staging_name())- } else {- dir.join(asset_name)- };+ // Legacy raw-binary assets can have the same name as the running executable.+ let staged_path = staged_asset_path(&dir, asset_name, is_archive);// Write to a temp file first, then rename for atomicity.let tmp_path = dir.join(format!(".{asset_name}.tmp"));diff --git a/crates/openhuman-core/src/platform/update/core_tests.rs b/crates/openhuman-core/src/platform/update/core_tests.rsindex 418dc56c43..bf92f83196 100644--- a/crates/openhuman-core/src/platform/update/core_tests.rs+++ b/crates/openhuman-core/src/platform/update/core_tests.rs@@ -450,3 +450,12 @@ fn staging_extracts_zip_when_archive_format_is_explicit() {b"core binary");}++#[test]+fn raw_core_binary_stages_separately_from_running_executable() {+ let dir = tempfile::TempDir::new().expect("temp dir");+ let staged = staged_asset_path(dir.path(), staged_binary_name(), false);++ assert_eq!(staged, dir.path().join(staged_binary_staging_name()));+ assert_ne!(staged, dir.path().join(staged_binary_name()));+}