Skip to content

Commit

Permalink
appmenus: do not fail qvm-appmenus --init on already existing dirs
Browse files Browse the repository at this point in the history
It may make sense to call qvm-appmenus --init second time on already
existing VM - for example giving --source this time. Also, do not crash
when retrying VM create/clone if previous try left some files.

QubesOS/qubes-issues#3902
  • Loading branch information
marmarek committed Oct 21, 2018
1 parent 844ba12 commit 54fa9d5
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions qubesappmenus/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -432,9 +432,9 @@ def appmenus_init(self, vm, src=None):
own_template_icons_dir = os.path.join(basedir, vm.name,
AppmenusSubdirs.template_icons_subdir)
if src is None:
os.makedirs(own_templates_dir)
os.makedirs(own_templates_dir, exist_ok=True)
os.makedirs(os.path.join(basedir, vm.name,
AppmenusSubdirs.template_icons_subdir))
AppmenusSubdirs.template_icons_subdir), exist_ok=True)

if vm.virt_mode == 'hvm' and src is None:
vm.log.info("Creating appmenus directory: {0}".format(
Expand Down Expand Up @@ -466,12 +466,16 @@ def appmenus_init(self, vm, src=None):
vm.log.info("Creating/copying appmenus templates")
src_dir = self.templates_dirs(src)[0]
if os.path.isdir(src_dir):
shutil.copytree(src_dir,
own_templates_dir)
os.makedirs(own_templates_dir, exist_ok=True)
for f in os.listdir(src_dir):
shutil.copy(os.path.join(src_dir, f),
own_templates_dir)
src_dir = self.template_icons_dirs(src)[0]
if os.path.isdir(src_dir):
shutil.copytree(src_dir,
own_template_icons_dir)
os.makedirs(own_template_icons_dir, exist_ok=True)
for f in os.listdir(src_dir):
shutil.copy(os.path.join(src_dir, f),
own_template_icons_dir)

@staticmethod
def set_default_whitelist(vm, applications_list):
Expand Down

0 comments on commit 54fa9d5

Please sign in to comment.