@ -73,11 +73,13 @@ pub async fn work_on_all(state: State) -> INodeInfoGraph
{
for ( path , ino ) in join_root ( & root , res )
{
if let Some ( _ ) = ino_map . get ( & ino ) {
output . insert ( path , ino ) ;
} else {
eprintln! ( "No ino entry for {:?} ({:?})" , path , ino ) ;
}
// 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 ) ;
//} else {
// eprintln!("No ino entry for {:?} ({:?})", path, ino);
//}
}
}
}
@ -99,43 +101,47 @@ fn walk(state: State, root: PathBuf, root_ino: INode) -> BoxFuture<'static, Hash
let mut output = HashMap ::new ( ) ;
let mut children : Vec < JoinHandle < HashMap < PathBuf , INode > > > = Vec ::new ( ) ;
async move {
match fs ::read_dir ( & root ) . await
{
Ok ( mut dir ) = > {
while let Some ( entry ) = dir . next ( ) . await
{
match entry
let _guard = state . lock ( ) . enter ( ) . await ;
println! ( " -> {:?}" , root ) ;
match fs ::read_dir ( & root ) . await
{
Ok ( mut dir ) = > {
while let Some ( entry ) = dir . next ( ) . await
{
Ok ( entry ) = > {
let ino = entry . inode ( ) ;
// Check cache for this
if state . cache ( ) . get ( & ino ) . await . is_none ( ) {
// Not added, process.
match process_entry ( & entry , root_ino ) . await {
Ok ( fsinfo ) = > {
if fsinfo . is_dir ( )
{
if let Some ( next ) = state . deepe r( )
match entry
{
Ok ( entry ) = > {
let ino = entry . inode ( ) ;
// Check cache for this
if state . cache ( ) . get ( & ino ) . await . is_none ( ) {
// Not added, process.
match process_entry ( & entry , root_ino ) . await {
Ok ( fsinfo ) = > {
if fsinfo . is_di r( )
{
children . push ( tokio ::spawn (
walk ( next , entry . path ( ) , ino )
) ) ;
if let Some ( next ) = state . deeper ( )
{
children . push ( tokio ::spawn (
walk ( next , entry . path ( ) , ino )
) ) ;
}
}
}
let mut cache = state . cache_sub ( ) ;
cache . insert ( ino , fsinfo ) . await ;
} ,
Err (err ) = > eprintln! ( "Failed to stat {:? }: {}", entry . path ( ) , err ) ,
let mut cache = state . cache_sub ( ) ;
cache . insert ( ino , fsinfo ) . await ;
} ,
Err ( err ) = > eprintln! ( "Failed to stat {:?}: {}" , entry . path ( ) , err ) ,
}
}
}
},
Err (err ) = > eprintln! ( "Walking {:? } failed: {}", root , err ) ,
} ,
Err (err ) = > eprintln! ( "Walking {:? } failed: {}", root , err ) ,
}
}
}
} ,
Err ( err ) = > eprintln! ( "Failed to walk {:?}: {}" , root , err ) ,
} ,
Err ( err ) = > eprintln! ( "Failed to walk {:?}: {}" , root , err ) ,
}
// drop work guard here
}
// Join all children
for child in join_all ( children . into_iter ( ) ) . await
{