appmenus: don't crash on VM without files on disk

Such VM can still trigger some appmenus-related action, for example
label change. This may happen during tests, or backup restore. And
probably some other cases.
This commit is contained in:
Marek Marczykowski-Górecki 2016-08-15 23:49:59 +02:00
parent fe209dfd24
commit 86ef6906ad
No known key found for this signature in database
GPG Key ID: 063938BA42CFA724

View File

@ -142,7 +142,10 @@ class AppmenusExtension(qubes.ext.Extension):
anything_changed = True anything_changed = True
templates_dir = self.templates_dir(vm) templates_dir = self.templates_dir(vm)
appmenus = os.listdir(templates_dir) if os.path.exists(templates_dir):
appmenus = os.listdir(templates_dir)
else:
appmenus = []
changed_appmenus = [] changed_appmenus = []
if os.path.exists(self.whitelist_path(vm)): if os.path.exists(self.whitelist_path(vm)):
whitelist = [x.rstrip() for x in open(self.whitelist_path(vm))] whitelist = [x.rstrip() for x in open(self.whitelist_path(vm))]