added parent inode to FsInfo:Directory

redo-gragh
Avril 3 years ago
parent 5592bc5d1b
commit 758d1bfe57
Signed by: flanchan
GPG Key ID: 284488987C31F630

@ -68,7 +68,7 @@ impl From<INode> for u64
pub enum FsInfo
{
File(u64, INode), //Size, parent dir inode
Directory,
Directory(INode), // Parent dir inode
}
impl FsInfo
@ -76,7 +76,7 @@ impl FsInfo
/// Is this entry a directory
#[inline] pub fn is_dir(&self) -> bool
{
if let Self::Directory = self
if let Self::Directory(_) = self
{
true
}

@ -25,7 +25,7 @@ async fn process_entry(entry: &tokio::fs::DirEntry, parent: INode) -> io::Result
let meta = entry.metadata().await?;
if meta.is_dir()
{
Ok(FsInfo::Directory)
Ok(FsInfo::Directory(parent))
} else if meta.is_file()
{
Ok(FsInfo::File(meta.len(), parent))
@ -35,17 +35,17 @@ async fn process_entry(entry: &tokio::fs::DirEntry, parent: INode) -> io::Result
}
}
/// Contains a graph of all paths and inodes that were successfully stat
/// 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 `file` contains parent INode that can be used to look up again in this table
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
//TODO: Order by largest size, get and iter fns etc
}
/// Walk on all paths in this state, then return a joined map of all

Loading…
Cancel
Save