app: reach the daemon and load the real history
The pipe path was missing a backslash, so every client call went to a path Windows never resolves and the app reported a dead daemon. With the path fixed, --probe answers against the running daemon and parses its settings with the app's model; a recording made through it lands on disk. Reading a large history (288 timelines, 524 MB of raw API responses) took eleven seconds, so the files are parsed on up to eight threads now. The history refresh also runs in headless runs, and `--live` renders a snapshot from the daemon and the real timelines instead of sample data.
This commit is contained in:
1 parent
8883e93d2b
commit
b06ec4be7b
5 files changed
+81
-32
No files matched your search
+36
-14
@@ -131,25 +131,47 @@ pub fn timeline_dir() -> PathBuf {
|
||||
}
|
||||
|
||||
/// Every timeline on disk, newest first. Files that fail to parse are skipped.
|
||||
/// Every timeline on disk, newest first. The raw API responses make each file large (hundreds
|
||||
/// of kilobytes), so the files are parsed in parallel.
|
||||
pub fn load_all() -> Vec<Timeline> {
|
||||
let dir = timeline_dir();
|
||||
let mut out = Vec::new();
|
||||
let Ok(entries) = std::fs::read_dir(&dir) else {
|
||||
return out;
|
||||
return Vec::new();
|
||||
};
|
||||
for entry in entries.flatten() {
|
||||
let path = entry.path();
|
||||
if path.extension().and_then(|e| e.to_str()) != Some("json") {
|
||||
continue;
|
||||
let paths: Vec<PathBuf> = entries
|
||||
.flatten()
|
||||
.map(|entry| entry.path())
|
||||
.filter(|path| path.extension().and_then(|e| e.to_str()) == Some("json"))
|
||||
.collect();
|
||||
|
||||
let next = std::sync::atomic::AtomicUsize::new(0);
|
||||
let parsed = std::sync::Mutex::new(Vec::with_capacity(paths.len()));
|
||||
let threads = std::thread::available_parallelism()
|
||||
.map(|count| count.get())
|
||||
.unwrap_or(4)
|
||||
.clamp(1, 8);
|
||||
|
||||
std::thread::scope(|scope| {
|
||||
for _ in 0..threads {
|
||||
scope.spawn(|| {
|
||||
loop {
|
||||
let index = next.fetch_add(1, std::sync::atomic::Ordering::Relaxed);
|
||||
let Some(path) = paths.get(index) else {
|
||||
break;
|
||||
};
|
||||
let Ok(text) = std::fs::read_to_string(path) else {
|
||||
continue;
|
||||
};
|
||||
match serde_json::from_str::<Timeline>(&text) {
|
||||
Ok(timeline) => parsed.lock().unwrap().push(timeline),
|
||||
Err(e) => eprintln!("skipping {}: {e}", path.display()),
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
let Ok(text) = std::fs::read_to_string(&path) else {
|
||||
continue;
|
||||
};
|
||||
match serde_json::from_str::<Timeline>(&text) {
|
||||
Ok(timeline) => out.push(timeline),
|
||||
Err(e) => eprintln!("skipping {}: {e}", path.display()),
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
let mut out = parsed.into_inner().unwrap();
|
||||
out.sort_by(|a, b| b.start_time.cmp(&a.start_time));
|
||||
out
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user