diff options
author | Matthias Beyer <mail@beyermatthias.de> | 2018-04-30 15:47:21 +0200 |
---|---|---|
committer | Matthias Beyer <mail@beyermatthias.de> | 2018-05-01 22:29:46 +0200 |
commit | 2bf09e7737febf0bdd3a2bd73d4eb89ad67229e6 (patch) | |
tree | 99b5e0a7141860cc7187a6336490b2da83d8d650 /lib | |
parent | 84f426297e1bb5e7fa1524844cdafce5be085530 (diff) |
Only create directory if it does not exist
Diffstat (limited to 'lib')
-rw-r--r-- | lib/core/libimagstore/src/file_abstraction/fs.rs | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/core/libimagstore/src/file_abstraction/fs.rs b/lib/core/libimagstore/src/file_abstraction/fs.rs index 42314502..b9d9186d 100644 --- a/lib/core/libimagstore/src/file_abstraction/fs.rs +++ b/lib/core/libimagstore/src/file_abstraction/fs.rs @@ -187,9 +187,12 @@ fn open_file<A: AsRef<Path>>(p: A) -> ::std::io::Result<File> { fn create_file<A: AsRef<Path>>(p: A) -> ::std::io::Result<File> { if let Some(parent) = p.as_ref().parent() { - debug!("Implicitely creating directory: {:?}", parent); - if let Err(e) = create_dir_all(parent) { - return Err(e); + trace!("'{}' is directory = {}", parent.display(), parent.is_dir()); + if !parent.is_dir() { + trace!("Implicitely creating directory: {:?}", parent); + if let Err(e) = create_dir_all(parent) { + return Err(e); + } } } OpenOptions::new().write(true).read(true).create(true).open(p) |