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