diff options
author | qkzk <qu3nt1n@gmail.com> | 2023-12-29 22:30:59 +0100 |
---|---|---|
committer | qkzk <qu3nt1n@gmail.com> | 2023-12-29 22:30:59 +0100 |
commit | 633ab32d08c5926e6612dec1c8302e527788d924 (patch) | |
tree | f89c2a721525fcac5c750a1a5dcf73d4ff186ca5 | |
parent | 27e9bfd11847263a1468fb45307df650f74ebfa9 (diff) |
FIX: entering inaccessible dir or writing to readonly dir crashes the app
-rw-r--r-- | development.md | 15 | ||||
-rw-r--r-- | src/event/event_exec.rs | 2 | ||||
-rw-r--r-- | src/io/opener.rs | 4 | ||||
-rw-r--r-- | src/modes/edit/leave_mode.rs | 27 |
4 files changed, 35 insertions, 13 deletions
diff --git a/development.md b/development.md index 2fad5fa..be72461 100644 --- a/development.md +++ b/development.md @@ -729,6 +729,7 @@ New view: Tree ! Toggle with 't', fold with 'z'. Navigate normally. - FIX: Tree mode. Unfolding a directory unfold its children - BREAKING: Use specific argument to run a command at startup for most common terminal emulators from config file. To make this work, it will require the user to update its config file by copying the last part: "terminal_emulator_flags:..." +- FIX: entering an inaccessible dir or writing in any way to a readonly dir shouldn't crash the app anymore... #### Changelog @@ -765,11 +766,15 @@ New view: Tree ! Toggle with 't', fold with 'z'. Navigate normally. - [x] FIX: unfold shouldn't unfold every child - [x] don't use -e for every terminal. See [rifle.conf](https://github.com/ranger/ranger/blob/136416c7e2ecc27315fe2354ecadfe09202df7dd/ranger/config/rifle.conf#L244) - [x] FIX: preview a symlink crashes the app -- [ ] FIX: opening an inaccessible dir crashes the app - - [ ] std set env crashes, don't ? it - - [ ] prevent entering like ranger does - - [ ] metadata le chemin avant. is_dir, metadata.permissions.readonly, metadata.permissions.writeonly - - [ ] fix toutes les écritures, check avant. Rename, Copy, Move, Delete, Trash, Untrash, Compress, Decompress +- [x] FIX: opening an inaccessible dir crashes the app + - [x] check std set env crashes before + - [x] check all writes + - [x] Rename, + - [x] Copy, Move, + - [x] Delete, + - [x] Trash, Untrash, + - [x] Compress, + - [x] Decompress - [ ] navigating in menus erase display - can't reproduce ? ## TODO diff --git a/src/event/event_exec.rs b/src/event/event_exec.rs index 46daeb4..c1d0b5c 100644 --- a/src/event/event_exec.rs +++ b/src/event/event_exec.rs @@ -851,7 +851,7 @@ impl EventAction { status.menu.trash.update()?; for flagged in status.menu.flagged.content.iter() { - status.menu.trash.trash(flagged)?; + let _ = status.menu.trash.trash(flagged); } status.menu.flagged.clear(); status.current_tab_mut().refresh_view()?; diff --git a/src/io/opener.rs b/src/io/opener.rs index 7f721dd..00df563 100644 --- a/src/io/opener.rs +++ b/src/io/opener.rs @@ -362,11 +362,11 @@ impl Opener { /// Only files opened with an external opener are supported. pub fn open_multiple(&self, paths: &[PathBuf]) -> Result<()> { for (external, grouped_paths) in &self.regroup_per_opener(paths) { - external.open( + let _ = external.open( &Self::collect_paths_as_str(grouped_paths), &self.terminal, &self.terminal_flag, - )?; + ); } Ok(()) } diff --git a/src/modes/edit/leave_mode.rs b/src/modes/edit/leave_mode.rs index df2e370..26a9a82 100644 --- a/src/modes/edit/leave_mode.rs +++ b/src/modes/edit/leave_mode.rs @@ -86,7 +86,7 @@ impl LeaveMode { /// Restore a file from the trash if possible. /// Parent folders are created if needed. pub fn trash(status: &mut Status) -> Result<()> { - status.menu.trash.restore()?; + let _ = status.menu.trash.restore(); status.reset_edit_mode()?; status.current_tab_mut().refresh_view()?; status.update_second_pane_for_preview() @@ -192,7 +192,13 @@ impl LeaveMode { pub fn rename(status: &mut Status) -> Result<()> { let old_path = status.current_tab().current_file()?.path; let new_name = status.menu.input.string(); - rename(old_path, new_name)?; + match rename(&old_path, &new_name) { + Ok(()) => (), + Err(error) => log_info!( + "Error renaming {old_path} to {new_name}. Error: {error}", + old_path = old_path.display() + ), + } status.current_tab_mut().refresh_view() } @@ -200,7 +206,10 @@ impl LeaveMode { /// Nothing is done if the file already exists. /// Filename is sanitized before processing. pub fn new_file(status: &mut Status) -> Result<()> { - NodeCreation::Newfile.create(status)?; + match NodeCreation::Newfile.create(status) { + Ok(()) => (), + Err(error) => log_info!("Error creating file. Error: {error}",), + } status.refresh_tabs() } @@ -210,7 +219,10 @@ impl LeaveMode { /// ie. the user can create `newdir` or `newdir/newfolder`. /// Directory name is sanitized before processing. pub fn new_dir(status: &mut Status) -> Result<()> { - NodeCreation::Newdir.create(status)?; + match NodeCreation::Newdir.create(status) { + Ok(()) => (), + Err(error) => log_info!("Error creating directory. Error: {error}",), + } status.refresh_tabs() } @@ -345,10 +357,15 @@ impl LeaveMode { if files_with_relative_paths.is_empty() { return Ok(()); } - status + match status .menu .compression .compress(files_with_relative_paths, here) + { + Ok(()) => (), + Err(error) => log_info!("Error compressing files. Error: {error}"), + } + Ok(()) } /// Open a menu with most common actions |