use std::path::PathBuf;
use std::time::{Duration, Instant};
use tokio::sync::oneshot;
use crate::collect;
use crate::model::{Tree, build_skeleton};
pub struct ScanOutcome {
pub tree: Tree,
pub duration: Duration,
pub repo: bool,
pub head: Option<String>,
}
pub fn spawn(root: PathBuf, root_label: String) -> oneshot::Receiver<ScanOutcome> {
let (tx, rx) = oneshot::channel();
tokio::task::spawn_blocking(move || {
let started = Instant::now();
let result = collect::walk(&root);
let tree = build_skeleton(&result.files, &result.dirs, root_label);
let repo = collect::is_repo(&root);
let head = collect::head_short_hash(&root);
let _ = tx.send(ScanOutcome {
tree,
duration: started.elapsed(),
repo,
head,
});
});
rx
}