From a98a8147e932b43e024232bda66b08f75a0bfd7f Mon Sep 17 00:00:00 2001 From: Lux Aliaga Date: Tue, 27 Sep 2022 21:23:43 -0300 Subject: [PATCH] item: Fix taking files recursively This should fix an issue which made it impossible to take files from directories other than the one the user is sitting at. --- src/item.rs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/item.rs b/src/item.rs index 4a2ca88..db6fbf0 100644 --- a/src/item.rs +++ b/src/item.rs @@ -55,7 +55,20 @@ pub fn take(file: &String, slot: &String) -> Result<()> { }; let sourcepath: PathBuf = Path::new(&file).to_path_buf(); - let destpath: PathBuf = [&slotdir, &Path::new(file).to_path_buf()].iter().collect(); + let destpath: PathBuf = [ + &slotdir, + &Path::new( + &Path::new(&file) + .file_name() + .unwrap() + .to_os_string() + .to_str() + .unwrap(), + ) + .to_path_buf(), + ] + .iter() + .collect(); if Path::exists(&destpath) { // Checks if there's a file with the same name in the inventory.