|
|
@ -1,5 +1,5 @@
|
|
|
|
use super::*;
|
|
|
|
use super::*;
|
|
|
|
use std::path::{Path, PathBuf};
|
|
|
|
use std::path::PathBuf;
|
|
|
|
use std::collections::HashMap;
|
|
|
|
use std::collections::HashMap;
|
|
|
|
use std::io;
|
|
|
|
use std::io;
|
|
|
|
|
|
|
|
|
|
|
@ -15,12 +15,6 @@ use data::FsInfo;
|
|
|
|
use state::State;
|
|
|
|
use state::State;
|
|
|
|
use data::INodeInfoGraph;
|
|
|
|
use data::INodeInfoGraph;
|
|
|
|
|
|
|
|
|
|
|
|
/// Join a root path onto this hashmap.
|
|
|
|
|
|
|
|
fn join_root<'a>(root: impl AsRef<Path> + 'a, map: HashMap<PathBuf, INode>) -> impl Iterator<Item=(PathBuf, INode)> + 'a
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
map.into_iter().map(move |(k, v)| (root.as_ref().join(k), v))
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async fn process_entry(entry: &tokio::fs::DirEntry, parent: INode) -> io::Result<FsInfo>
|
|
|
|
async fn process_entry(entry: &tokio::fs::DirEntry, parent: INode) -> io::Result<FsInfo>
|
|
|
|
{
|
|
|
|
{
|
|
|
|
let meta = entry.metadata().await?;
|
|
|
|
let meta = entry.metadata().await?;
|
|
|
@ -50,7 +44,6 @@ pub async fn work_on_all(state: State) -> INodeInfoGraph
|
|
|
|
let inode = meta.inode();
|
|
|
|
let inode = meta.inode();
|
|
|
|
tokio::spawn(walk(state.clone(), path, inode)).await
|
|
|
|
tokio::spawn(walk(state.clone(), path, inode)).await
|
|
|
|
.ok()
|
|
|
|
.ok()
|
|
|
|
//.map(move |res| (res, path))
|
|
|
|
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Err(err) => {
|
|
|
|
Err(err) => {
|
|
|
|
eprintln!("Failed to stat root {:?}: {}", path, err);
|
|
|
|
eprintln!("Failed to stat root {:?}: {}", path, err);
|
|
|
@ -72,19 +65,7 @@ pub async fn work_on_all(state: State) -> INodeInfoGraph
|
|
|
|
if let Some(res) = path_comp
|
|
|
|
if let Some(res) = path_comp
|
|
|
|
{
|
|
|
|
{
|
|
|
|
output.extend(res);
|
|
|
|
output.extend(res);
|
|
|
|
/*
|
|
|
|
|
|
|
|
for (path, ino) in res.into_iter()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
// If this inode is not in the map, this is a top-level path.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//if let Some(_) = ino_map.get(&ino) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
output.insert(path, ino); //XXX: Why does `output` always end up empty???
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//} else {
|
|
|
|
|
|
|
|
// eprintln!("No ino entry for {:?} ({:?})", path, ino);
|
|
|
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
}*/
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -153,7 +134,7 @@ fn walk(state: State, root: PathBuf, root_ino: INode) -> BoxFuture<'static, Hash
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if let Ok(map) = child
|
|
|
|
if let Ok(map) = child
|
|
|
|
{
|
|
|
|
{
|
|
|
|
output.extend(map);//join_root(&root, map));
|
|
|
|
output.extend(map);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
eprintln!("Child panic");
|
|
|
|
eprintln!("Child panic");
|
|
|
|
}
|
|
|
|
}
|
|
|
|