only create folder if target parent exists

This commit is contained in:
j 2019-01-23 00:32:11 +05:30
parent 31e91d16bf
commit 7f05b08238

View file

@ -129,9 +129,11 @@ def get_icons_db_path():
import settings import settings
import shutil import shutil
metadata = os.path.join(os.path.expanduser(settings.preferences['libraryPath']), 'Metadata') library = os.path.expanduser(settings.preferences['libraryPath'])
ox.makedirs(metadata) metadata = os.path.join(library, 'Metadata')
icons_db_path = os.path.join(metadata, 'icons.db') icons_db_path = os.path.join(metadata, 'icons.db')
if os.path.exists(os.path.dirname(library)):
ox.makedirs(metadata)
old_icons_db_path = os.path.join(settings.data_path, 'icons.db') old_icons_db_path = os.path.join(settings.data_path, 'icons.db')
if not os.path.exists(icons_db_path) and os.path.exists(old_icons_db_path): if not os.path.exists(icons_db_path) and os.path.exists(old_icons_db_path):
shutil.move(old_icons_db_path, icons_db_path) shutil.move(old_icons_db_path, icons_db_path)