From 758d1bfe57cd75b294f4734c17bd3d5699a76608 Mon Sep 17 00:00:00 2001 From: Avril Date: Tue, 9 Feb 2021 19:00:18 +0000 Subject: [PATCH] added parent inode to FsInfo:Directory --- src/data/mod.rs | 4 ++-- src/work.rs | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/data/mod.rs b/src/data/mod.rs index 301cc6c..d7e24d2 100644 --- a/src/data/mod.rs +++ b/src/data/mod.rs @@ -68,7 +68,7 @@ impl From 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 } diff --git a/src/work.rs b/src/work.rs index a40ae43..977ae05 100644 --- a/src/work.rs +++ b/src/work.rs @@ -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, // FsInfo `file` contains parent INode that can be used to look up again in this table + inodes: HashMap, // FsInfo contains parent INode that can be used to look up again in this table paths: HashMap, // 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