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,12 +129,14 @@ 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')
old_icons_db_path = os.path.join(settings.data_path, 'icons.db') if os.path.exists(os.path.dirname(library)):
if not os.path.exists(icons_db_path) and os.path.exists(old_icons_db_path): ox.makedirs(metadata)
shutil.move(old_icons_db_path, icons_db_path) 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):
shutil.move(old_icons_db_path, icons_db_path)
return icons_db_path return icons_db_path
def get_icon_sync(id, type_, size): def get_icon_sync(id, type_, size):