From b285a6476e5981cc78fba9d5ce16cea8cf5f51a2 Mon Sep 17 00:00:00 2001 From: blek Date: Sat, 9 Dec 2023 22:14:09 +1000 Subject: [PATCH] refactor code for readability --- filed/src/files/lookup.rs | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/filed/src/files/lookup.rs b/filed/src/files/lookup.rs index 3e67233..63210a7 100644 --- a/filed/src/files/lookup.rs +++ b/filed/src/files/lookup.rs @@ -109,11 +109,22 @@ impl FileManager { match kind { LookupKind::ByName => { - if (&file).name.is_none() { + if let Some(name) = file.name.clone() { + log::debug!("Using {} as a custom file name", name); + return Ok(self.save_int( + &file, + format!( + "{}{}{}", + self.env.redis.prefix, + midfix, + name + ) + )?) + } else { return Err("Filename can't be None when LookupKind is ByName!".into()) } } - _ => () + _ => log::debug!("No custom file name detected") } self.save_int( @@ -122,10 +133,7 @@ impl FileManager { "{}{}{}", self.env.redis.prefix, midfix, - match kind { - LookupKind::ByName => (&file).name.as_ref().unwrap().clone(), - LookupKind::ByHash => (&file).hash() - } + file.hash() ) ) }