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.
This commit is contained in:
Lux Aliaga 2022-09-27 21:23:43 -03:00
parent 6ec32037db
commit a98a8147e9
Signed by: lux
GPG Key ID: B56C805968637437
1 changed files with 14 additions and 1 deletions

View File

@ -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.