Rewrite untitialized directory detection
This commit is contained in:
parent
23321bd300
commit
47db0898e2
1 changed files with 17 additions and 15 deletions
|
@ -74,15 +74,17 @@ def importBundle(bundle):
|
||||||
|
|
||||||
def init_dirs():
|
def init_dirs():
|
||||||
data_dir = config.data_dir
|
data_dir = config.data_dir
|
||||||
if not os.path.isdir(data_dir):
|
has_data_dir = os.path.isdir(data_dir)
|
||||||
|
need_bootstrap = not config.disable_bootstrap and (not has_data_dir or not os.path.isfile(f'{data_dir}/sites.json')) and not config.offline
|
||||||
|
|
||||||
|
if not has_data_dir:
|
||||||
os.mkdir(data_dir)
|
os.mkdir(data_dir)
|
||||||
try:
|
try:
|
||||||
os.chmod(data_dir, stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR)
|
os.chmod(data_dir, stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR)
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
startupError(f"Can't change permission of {data_dir}: {err}")
|
startupError(f"Can't change permission of {data_dir}: {err}")
|
||||||
|
|
||||||
# download latest bootstrap bundle
|
if need_bootstrap:
|
||||||
if not config.disable_bootstrap and not config.offline:
|
|
||||||
import requests
|
import requests
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue