move INodeInfoGraph to data module

redo-gragh
Avril 4 years ago
parent 758d1bfe57
commit 47b5e97006
Signed by: flanchan
GPG Key ID: 284488987C31F630

@ -0,0 +1,24 @@
use super::*;
use std::collections::HashMap;
use std::path::PathBuf;
/// Contains a graph of all paths and inodes that were successfully stat'd
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct INodeInfoGraph
{
inodes: HashMap<INode, FsInfo>, // FsInfo contains parent INode that can be used to look up again in this table
paths: HashMap<PathBuf, INode>, // map absolute paths to INodes to be looked up in `inodes` table.
}
impl INodeInfoGraph
{
/// Create a new graph from these linked `HashMap`s
#[inline] pub fn new(inodes: HashMap<INode, FsInfo>, paths: HashMap<PathBuf, INode>) -> Self
{
Self {
inodes,
paths
}
}
//TODO: Order by largest size, get and iter fns etc
}

@ -13,6 +13,7 @@ pub const CACHE_GATE_TIMEOUT: Duration = duration!(100 ms);
pub const CACHE_GATED_LAG: Duration = duration!(10 ms);
mod cache; pub use cache::Cache;
pub mod graph; pub use graph::INodeInfoGraph;
/// A raw file or directory inode number
///
@ -60,6 +61,8 @@ impl From<INode> for u64
}
}
/// A valid file system info
///
/// # Note

@ -13,6 +13,7 @@ use tokio::fs;
use data::INode;
use data::FsInfo;
use state::State;
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
@ -35,19 +36,6 @@ async fn process_entry(entry: &tokio::fs::DirEntry, parent: INode) -> io::Result
}
}
/// Contains a graph of all paths and inodes that were successfully stat'd
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct INodeInfoGraph
{
inodes: HashMap<INode, FsInfo>, // FsInfo contains parent INode that can be used to look up again in this table
paths: HashMap<PathBuf, INode>, // map absolute paths to INodes to be looked up in `inodes` table.
}
impl INodeInfoGraph
{
//TODO: Order by largest size, get and iter fns etc
}
/// Walk on all paths in this state, then return a joined map of all
///
/// # Panics
@ -94,10 +82,10 @@ pub async fn work_on_all(state: State) -> INodeInfoGraph
}
}
INodeInfoGraph {
inodes: ino_map,
paths: output,
}
INodeInfoGraph::new(
ino_map,
output,
)
}
/// Walk this directory.

Loading…
Cancel
Save