Skip to content

Commit

Permalink
Merge pull request #17 from AmineZouitine/synbolic
Browse files Browse the repository at this point in the history
fix symbolic links errors
  • Loading branch information
AmineZouitine authored Oct 13, 2022
2 parents a7e002a + 5d540d6 commit 97050bf
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ shellexpand = "2.1.2"
rustyline = "10.0.0"
colored = "2.0.0"
termion = "1.5.6"
clap = { version = "4.0.13", features = ["derive"] }
clap = { version = "4.0.13", features = ["derive"] }
12 changes: 10 additions & 2 deletions src/trash_manager.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::arguments_manager::ArgumentsManager;
use crate::display_manager;
use crate::structure_manager::{self, get_home_directory_path};
use crate::structure_manager::{self, get_element_name, get_element_path, get_home_directory_path};
use crate::{
config::Config, data_manager, structure_manager::get_trash_directory_path,
trash_item::TrashItem,
Expand Down Expand Up @@ -29,7 +29,7 @@ pub fn add_element_to_trash(
is_test: bool,
arguments_manager: &ArgumentsManager,
) {
let element_path = match abspath(element_name) {
let mut element_path = match abspath(element_name) {
Some(path) => {
if Path::new(&path).is_dir() {
let element_in_dir = fs::read_dir(&path).unwrap().count();
Expand Down Expand Up @@ -81,6 +81,14 @@ pub fn add_element_to_trash(
if config.compression {
// TODO
} else {
let symbolic_path = format!(
"{}/{}",
get_element_path(&element_path),
get_element_name(element_name)
);
if symbolic_path != element_path {
element_path = symbolic_path;
}
fs::rename(&element_path, &new_name).unwrap();
}

Expand Down

0 comments on commit 97050bf

Please sign in to comment.