Made config folder creation recursive

This commit is contained in:
uh_wot 2020-05-18 12:31:56 +02:00
parent 1a95f16ba0
commit 65ca1652c0
1 changed files with 3 additions and 4 deletions

View File

@ -1,7 +1,7 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
import json import json
import os.path as path import os.path as path
from os import mkdir, makedirs from os import makedirs
import deemix.utils.localpaths as localpaths import deemix.utils.localpaths as localpaths
@ -14,8 +14,7 @@ def initSettings():
global defaultSettings global defaultSettings
currentFolder = path.abspath(path.dirname(__file__)) currentFolder = path.abspath(path.dirname(__file__))
configFolder = localpaths.getConfigFolder() configFolder = localpaths.getConfigFolder()
if not path.isdir(configFolder): makedirs(configFolder, exist_ok=True)
mkdir(configFolder)
with open(path.join(currentFolder, 'default.json'), 'r') as d: with open(path.join(currentFolder, 'default.json'), 'r') as d:
defaultSettings = json.load(d) defaultSettings = json.load(d)
defaultSettings['downloadLocation'] = path.join(localpaths.getHomeFolder(), 'deemix Music') defaultSettings['downloadLocation'] = path.join(localpaths.getHomeFolder(), 'deemix Music')
@ -27,7 +26,7 @@ def initSettings():
settingsCheck() settingsCheck()
if settings['downloadLocation'] == "": if settings['downloadLocation'] == "":
settings['downloadLocation'] = path.join(localpaths.getHomeFolder(), 'deemix Music') settings['downloadLocation'] = path.join(localpaths.getHomeFolder(), 'deemix Music')
saveSettings(settings) saveSettings(settings)
makedirs(settings['downloadLocation'], exist_ok=True) makedirs(settings['downloadLocation'], exist_ok=True)
return settings return settings