Browse Source

Do not delete dir on file delete

Previously during a `delete_file` check we also tried to delete the
parent directory and ignored all errors, like not being empty for
example.

Since this function is called `delete_file` and does not mention
anything in regards to a directory i have removed that code and it will
now only delete the file and leave the rest as-is.

If this somehow is still needed or wanted, which i do not think we want,
then we should create a new function.

Fixes #4081
pull/4143/head
BlackDex 2 years ago
parent
commit
15d652088e
No known key found for this signature in database GPG Key ID: 58C80A2AA6C765E1
  1. 10
      src/util.rs

10
src/util.rs

@ -363,15 +363,7 @@ pub fn write_file(path: &str, content: &[u8]) -> Result<(), crate::error::Error>
}
pub fn delete_file(path: &str) -> IOResult<()> {
let res = fs::remove_file(path);
if let Some(parent) = Path::new(path).parent() {
// If the directory isn't empty, this returns an error, which we ignore
// We only want to delete the folder if it's empty
fs::remove_dir(parent).ok();
}
res
fs::remove_file(path)
}
pub fn get_display_size(size: i32) -> String {

Loading…
Cancel
Save