Create directories only if feature is enabled

This commit is contained in:
Tomasz Drwięga 2016-11-15 10:28:52 +01:00
parent 9857f632d8
commit 6ea4b25859
3 changed files with 10 additions and 6 deletions

View File

@ -117,7 +117,7 @@ fn execute_import(cmd: ImportBlockchain) -> Result<String, String> {
let panic_handler = PanicHandler::new_in_arc(); let panic_handler = PanicHandler::new_in_arc();
// create dirs used by parity // create dirs used by parity
try!(cmd.dirs.create_dirs()); try!(cmd.dirs.create_dirs(false, false));
// load spec file // load spec file
let spec = try!(cmd.spec.spec()); let spec = try!(cmd.spec.spec());
@ -263,7 +263,7 @@ fn execute_export(cmd: ExportBlockchain) -> Result<String, String> {
let panic_handler = PanicHandler::new_in_arc(); let panic_handler = PanicHandler::new_in_arc();
// create dirs used by parity // create dirs used by parity
try!(cmd.dirs.create_dirs()); try!(cmd.dirs.create_dirs(false, false));
let format = cmd.format.unwrap_or_default(); let format = cmd.format.unwrap_or_default();

View File

@ -44,11 +44,15 @@ impl Default for Directories {
} }
impl 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.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.keys).map_err(|e| e.to_string()));
try!(fs::create_dir_all(&self.signer).map_err(|e| e.to_string())); if signer_enabled {
try!(fs::create_dir_all(&self.dapps).map_err(|e| e.to_string())); 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(()) Ok(())
} }

View File

@ -110,7 +110,7 @@ pub fn execute(cmd: RunCmd, logger: Arc<RotatingLogger>) -> Result<(), String> {
raise_fd_limit(); raise_fd_limit();
// create dirs used by parity // 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 // load spec
let spec = try!(cmd.spec.spec()); let spec = try!(cmd.spec.spec());