Skip to content

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

style(update): rustfmt the restored matcher and staging helpers

obchain9a069d34be29
diff --git a/crates/openhuman-core/src/platform/update/core.rs b/crates/openhuman-core/src/platform/update/core.rs
index 233470d5e3..381ddbbca8 100644
--- a/crates/openhuman-core/src/platform/update/core.rs
+++ b/crates/openhuman-core/src/platform/update/core.rs
@@ -136,7 +136,10 @@ fn finalize_executable(tmp: &std::path::Path, dest: &std::path::Path) -> Result<
/// Without this the archive itself was written to the staging path and marked
/// executable, so a restart would try to exec a tarball. Restored from #908,
/// which added it for exactly that reason.
-fn extract_core_binary(archive_path: &std::path::Path, dest: &std::path::Path) -> Result<(), String> {
+fn extract_core_binary(
+ archive_path: &std::path::Path,
+ dest: &std::path::Path,
+) -> Result<(), String> {
let inner_name = staged_binary_name();
let archive_name = archive_path
.file_name()
@@ -152,10 +155,11 @@ fn extract_core_binary(archive_path: &std::path::Path, dest: &std::path::Path) -
.by_name(inner_name)
.map_err(|e| format!("archive has no '{inner_name}' entry: {e}"))?;
{
- let mut out =
- std::fs::File::create(&tmp_path).map_err(|e| format!("create staging temp: {e}"))?;
+ let mut out = std::fs::File::create(&tmp_path)
+ .map_err(|e| format!("create staging temp: {e}"))?;
std::io::copy(&mut entry, &mut out).map_err(|e| format!("extract zip entry: {e}"))?;
- out.flush().map_err(|e| format!("flush extracted binary: {e}"))?;
+ out.flush()
+ .map_err(|e| format!("flush extracted binary: {e}"))?;
}
return finalize_executable(&tmp_path, dest);
}
@@ -167,7 +171,9 @@ fn extract_core_binary(archive_path: &std::path::Path, dest: &std::path::Path) -
.map_err(|e| format!("read tar entries: {e}"))?;
for entry in entries {
let mut entry = entry.map_err(|e| format!("read tar entry: {e}"))?;
- let path = entry.path().map_err(|e| format!("read tar entry path: {e}"))?;
+ let path = entry
+ .path()
+ .map_err(|e| format!("read tar entry path: {e}"))?;
let is_core = path
.file_name()
.and_then(|s| s.to_str())
@@ -176,10 +182,11 @@ fn extract_core_binary(archive_path: &std::path::Path, dest: &std::path::Path) -
continue;
}
{
- let mut out =
- std::fs::File::create(&tmp_path).map_err(|e| format!("create staging temp: {e}"))?;
+ let mut out = std::fs::File::create(&tmp_path)
+ .map_err(|e| format!("create staging temp: {e}"))?;
std::io::copy(&mut entry, &mut out).map_err(|e| format!("extract tar entry: {e}"))?;
- out.flush().map_err(|e| format!("flush extracted binary: {e}"))?;
+ out.flush()
+ .map_err(|e| format!("flush extracted binary: {e}"))?;
}
return finalize_executable(&tmp_path, dest);
}
diff --git a/crates/openhuman-core/src/platform/update/core_tests.rs b/crates/openhuman-core/src/platform/update/core_tests.rs
index 97312742c3..f0b44dd8c8 100644
--- a/crates/openhuman-core/src/platform/update/core_tests.rs
+++ b/crates/openhuman-core/src/platform/update/core_tests.rs
@@ -168,7 +168,6 @@ fn the_default_origin_is_still_the_pinned_github_api() {
);
}
-
// ---------------------------------------------------------------------------
// #6766: the release publishes the core as `openhuman-core-<version>-<triple>`
// with the version BETWEEN the prefix and the triple, so matching on
@@ -181,7 +180,11 @@ fn the_default_origin_is_still_the_pinned_github_api() {
/// The archive extension the release workflow publishes for this platform.
fn archive_ext() -> &'static str {
- if cfg!(windows) { ".zip" } else { ".tar.gz" }
+ if cfg!(windows) {
+ ".zip"
+ } else {
+ ".tar.gz"
+ }
}
fn asset(name: &str) -> GitHubAsset {
@@ -204,7 +207,10 @@ fn find_platform_asset_matches_the_versioned_archive() {
let picked = find_platform_asset(&assets).expect("the versioned archive must be selected");
- assert_eq!(picked.name, wanted, "another triple's archive must not be selected");
+ assert_eq!(
+ picked.name, wanted,
+ "another triple's archive must not be selected"
+ );
}
#[test]
@@ -268,8 +274,12 @@ fn find_platform_asset_returns_none_when_no_core_asset_is_published() {
#[test]
fn is_archive_asset_classifies_the_published_shapes() {
- assert!(is_archive_asset("openhuman-core-0.64.7-x86_64-unknown-linux-gnu.tar.gz"));
- assert!(is_archive_asset("openhuman-core-0.64.7-x86_64-pc-windows-msvc.zip"));
+ assert!(is_archive_asset(
+ "openhuman-core-0.64.7-x86_64-unknown-linux-gnu.tar.gz"
+ ));
+ assert!(is_archive_asset(
+ "openhuman-core-0.64.7-x86_64-pc-windows-msvc.zip"
+ ));
assert!(is_archive_asset("core.tgz"));
assert!(!is_archive_asset("openhuman-core-x86_64-unknown-linux-gnu"));
assert!(!is_archive_asset("openhuman-core.exe"));
@@ -315,7 +325,12 @@ async fn check_available_picks_the_versioned_archive() {
/// Build a `.tar.gz` holding one entry named `entry_name`, with `body` as its
/// contents, and return its path.
#[cfg(unix)]
-fn write_tar_gz(dir: &std::path::Path, archive_name: &str, entry_name: &str, body: &[u8]) -> std::path::PathBuf {
+fn write_tar_gz(
+ dir: &std::path::Path,
+ archive_name: &str,
+ entry_name: &str,
+ body: &[u8],
+) -> std::path::PathBuf {
let archive_path = dir.join(archive_name);
let file = std::fs::File::create(&archive_path).expect("create archive");
let encoder = flate2::write::GzEncoder::new(file, flate2::Compression::fast());
@@ -327,7 +342,11 @@ fn write_tar_gz(dir: &std::path::Path, archive_name: &str, entry_name: &str, bod
builder
.append_data(&mut header, entry_name, body)
.expect("append entry");
- builder.into_inner().expect("finish tar").finish().expect("finish gz");
+ builder
+ .into_inner()
+ .expect("finish tar")
+ .finish()
+ .expect("finish gz");
archive_path
}
@@ -352,8 +371,15 @@ fn staging_extracts_the_core_binary_out_of_the_archive() {
b"#!/bin/sh\nexit 0\n",
"the staged file must be the inner binary, not the archive"
);
- let mode = std::fs::metadata(&dest).expect("stat staged binary").permissions().mode();
- assert_eq!(mode & 0o111, 0o111, "the staged binary must be executable, mode was {mode:o}");
+ let mode = std::fs::metadata(&dest)
+ .expect("stat staged binary")
+ .permissions()
+ .mode();
+ assert_eq!(
+ mode & 0o111,
+ 0o111,
+ "the staged binary must be executable, mode was {mode:o}"
+ );
}
#[cfg(unix)]
@@ -376,5 +402,8 @@ fn staging_refuses_an_archive_without_the_core_binary() {
err.contains(staged_binary_name()),
"the error must name the entry it looked for, got: {err}"
);
- assert!(!dest.exists(), "nothing may be staged when extraction fails");
+ assert!(
+ !dest.exists(),
+ "nothing may be staged when extraction fails"
+ );
}