From 6ea4b258591ed55fecfe3238d0e599175b59d492 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Drwi=C4=99ga?= Date: Tue, 15 Nov 2016 10:28:52 +0100 Subject: [PATCH] Create directories only if feature is enabled --- parity/blockchain.rs | 4 ++-- parity/dir.rs | 10 +++++++--- parity/run.rs | 2 +- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/parity/blockchain.rs b/parity/blockchain.rs index 9575b293a..75a589d68 100644 --- a/parity/blockchain.rs +++ b/parity/blockchain.rs @@ -117,7 +117,7 @@ fn execute_import(cmd: ImportBlockchain) -> Result { let panic_handler = PanicHandler::new_in_arc(); // create dirs used by parity - try!(cmd.dirs.create_dirs()); + try!(cmd.dirs.create_dirs(false, false)); // load spec file let spec = try!(cmd.spec.spec()); @@ -263,7 +263,7 @@ fn execute_export(cmd: ExportBlockchain) -> Result { let panic_handler = PanicHandler::new_in_arc(); // create dirs used by parity - try!(cmd.dirs.create_dirs()); + try!(cmd.dirs.create_dirs(false, false)); let format = cmd.format.unwrap_or_default(); diff --git a/parity/dir.rs b/parity/dir.rs index d7638e33b..b9c02efd6 100644 --- a/parity/dir.rs +++ b/parity/dir.rs @@ -44,11 +44,15 @@ impl Default for Directories { } impl Directories { - pub fn create_dirs(&self) -> Result<(), String> { + pub fn create_dirs(&self, dapps_enabled: bool, signer_enabled: bool) -> Result<(), String> { try!(fs::create_dir_all(&self.db).map_err(|e| e.to_string())); try!(fs::create_dir_all(&self.keys).map_err(|e| e.to_string())); - try!(fs::create_dir_all(&self.signer).map_err(|e| e.to_string())); - try!(fs::create_dir_all(&self.dapps).map_err(|e| e.to_string())); + if signer_enabled { + try!(fs::create_dir_all(&self.signer).map_err(|e| e.to_string())); + } + if dapps_enabled { + try!(fs::create_dir_all(&self.dapps).map_err(|e| e.to_string())); + } Ok(()) } diff --git a/parity/run.rs b/parity/run.rs index 56ff92c25..9fdd811de 100644 --- a/parity/run.rs +++ b/parity/run.rs @@ -110,7 +110,7 @@ pub fn execute(cmd: RunCmd, logger: Arc) -> Result<(), String> { raise_fd_limit(); // create dirs used by parity - try!(cmd.dirs.create_dirs()); + try!(cmd.dirs.create_dirs(cmd.dapps_conf.enabled, cmd.signer_conf.enabled)); // load spec let spec = try!(cmd.spec.spec());