Skip to content

Commit

Permalink
Fix deletion of root directory
Browse files Browse the repository at this point in the history
This PR adds a check in the remove_dir_all method to avoid removing the root directory.
This Gives a simple fix to the case where one wants to remove all files in the filesystem,
and therefore calls remove_dir_all on `/`, which would previously fail because it can't delete the root.
  • Loading branch information
sosthene-nitrokey committed Sep 1, 2023
1 parent 8eb6b4e commit e7e7364
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ pub type Bytes<SIZE> = generic_array::GenericArray<u8, SIZE>;
use crate::{
driver,
io::{self, OpenSeekFrom, Result},
path,
path::{Path, PathBuf},
};

Expand Down Expand Up @@ -358,7 +359,7 @@ impl<Storage: driver::Storage> Filesystem<'_, Storage> {
}
Ok(())
})?;
if !skipped_any {
if !skipped_any && path != path!("") && path != path!("/") {
debug_now!("removing directory {} too", &path);
self.remove_dir(path)?;
debug_now!("..worked");
Expand Down

0 comments on commit e7e7364

Please sign in to comment.