From 2bf09e7737febf0bdd3a2bd73d4eb89ad67229e6 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Mon, 30 Apr 2018 15:47:21 +0200 Subject: [PATCH] Only create directory if it does not exist --- lib/core/libimagstore/src/file_abstraction/fs.rs | 9 ++++++--- 1 file 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>(p: A) -> ::std::io::Result { fn create_file>(p: A) -> ::std::io::Result { 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)