From 650f504fbf1607d03ea6f2d63853f0918d75dc9d Mon Sep 17 00:00:00 2001 From: SomberNight Date: Wed, 13 Dec 2017 12:00:16 +0100 Subject: [PATCH] fix: testnet datadir could not be created first --- lib/simple_config.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/lib/simple_config.py b/lib/simple_config.py index c28a85b90..237956f27 100644 --- a/lib/simple_config.py +++ b/lib/simple_config.py @@ -85,15 +85,18 @@ class SimpleConfig(PrintError): if path is None: path = self.user_dir() + def make_dir(path): + # Make directory if it does not yet exist. + if not os.path.exists(path): + if os.path.islink(path): + raise BaseException('Dangling link: ' + path) + os.mkdir(path) + os.chmod(path, stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR) + + make_dir(path) if self.get('testnet'): path = os.path.join(path, 'testnet') - - # Make directory if it does not yet exist. - if not os.path.exists(path): - if os.path.islink(path): - raise BaseException('Dangling link: ' + path) - os.mkdir(path) - os.chmod(path, stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR) + make_dir(path) self.print_error("electrum directory", path) return path