fix(#1164,#1171): harness writes status file, c0re just rescans
This commit is contained in:
parent
a9ce8a945f
commit
049ae47191
5 changed files with 75 additions and 26 deletions
|
|
@ -303,7 +303,17 @@ fn auth_failed_sentinel(name: &str) -> bool {
|
|||
pub fn read_agent_status(name: &str) -> (Option<String>, Option<i64>) {
|
||||
let path = Coordinator::agent_notes_dir(name).join("hyperhive-status");
|
||||
let meta = std::fs::metadata(&path).ok();
|
||||
let s = std::fs::read_to_string(&path).ok();
|
||||
// Read at most STATUS_MAX_CHARS * 4 + 2 bytes: 4 is the max UTF-8 byte
|
||||
// width per char, +2 for the trailing newline. Guards against a
|
||||
// pathologically large file written outside the harness validation path.
|
||||
let s = {
|
||||
use std::io::Read as _;
|
||||
std::fs::File::open(&path).ok().and_then(|f| {
|
||||
let cap = (crate::limits::STATUS_MAX_CHARS * 4 + 2) as u64;
|
||||
let mut buf = String::new();
|
||||
f.take(cap).read_to_string(&mut buf).ok().map(|_| buf)
|
||||
})
|
||||
};
|
||||
let text = s
|
||||
.as_deref()
|
||||
.map(str::trim)
|
||||
|
|
|
|||
Loading…
Reference in a new issue