From 8ce3f99585cfa6db6d87b49bf5a24cb99c97bb03 Mon Sep 17 00:00:00 2001 From: ChanTsune <41658782+ChanTsune@users.noreply.github.com> Date: Mon, 12 Aug 2024 23:24:40 +0900 Subject: [PATCH] :recycle: Remove password field from FileManager --- src/file_manager.rs | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/file_manager.rs b/src/file_manager.rs index 5f2220f..2993afa 100644 --- a/src/file_manager.rs +++ b/src/file_manager.rs @@ -166,7 +166,6 @@ const ROOT_INODE: Inode = 1; pub(crate) struct FileManager { archive_path: PathBuf, - password: Option, tree: Tree, files: HashMap, node_ids: HashMap, @@ -177,22 +176,20 @@ impl FileManager { pub(crate) fn new(archive_path: PathBuf, password: Option) -> Self { let mut mamager = Self { archive_path, - password, tree: TreeBuilder::new().build(), files: HashMap::new(), node_ids: HashMap::new(), last_inode: ROOT_INODE, }; - mamager.populate().unwrap(); + mamager.populate(password.as_deref()).unwrap(); mamager } - fn populate(&mut self) -> io::Result<()> { + fn populate(&mut self, password: Option<&str>) -> io::Result<()> { self.add_root_file(File::root(ROOT_INODE))?; let file = fs::File::open(&self.archive_path)?; let mut archive = Archive::read_header(file)?; - let password = self.password.clone(); - for entry in archive.entries_with_password(password.as_deref()) { + for entry in archive.entries_with_password(password) { let entry = entry?; let parents = entry.header().path().as_path().parent(); let parent = if let Some(parents) = parents { @@ -200,7 +197,7 @@ impl FileManager { } else { ROOT_INODE }; - let file = File::from_entry(self.next_inode(), entry, password.as_ref()); + let file = File::from_entry(self.next_inode(), entry, password); self.add_or_update_file(file, parent)?; } Ok(())