appmenus: do nothing if VM isn't created on disk yet

This may be a case during backup restore - some properties may be
modifier before restoring actual files.

QubesOS/qubes-issues#1897
This commit is contained in:
Marek Marczykowski-Górecki 2016-05-25 03:28:38 +02:00
parent aef9aa2dd3
commit 19609705fc
No known key found for this signature in database
GPG Key ID: 063938BA42CFA724

View File

@ -298,10 +298,14 @@ class AppmenusExtension(qubes.ext.Extension):
@qubes.ext.handler('property-pre-set:name') @qubes.ext.handler('property-pre-set:name')
def pre_rename(self, vm, event, prop, *args): def pre_rename(self, vm, event, prop, *args):
if not os.path.exists(vm.dir_path):
return
self.appmenus_remove(vm) self.appmenus_remove(vm)
@qubes.ext.handler('property-set:name') @qubes.ext.handler('property-set:name')
def post_rename(self, vm, event, prop, *args): def post_rename(self, vm, event, prop, *args):
if not os.path.exists(vm.dir_path):
return
self.appmenus_create(vm) self.appmenus_create(vm)
@qubes.ext.handler('domain-create-on-disk') @qubes.ext.handler('domain-create-on-disk')
@ -384,6 +388,8 @@ class AppmenusExtension(qubes.ext.Extension):
@qubes.ext.handler('property-set:label') @qubes.ext.handler('property-set:label')
def label_setter(self, vm, event, *args): def label_setter(self, vm, event, *args):
if not os.path.exists(vm.dir_path):
return
self.appicons_create(vm, force=True) self.appicons_create(vm, force=True)
# Apparently desktop environments heavily caches the icons, # Apparently desktop environments heavily caches the icons,
@ -412,6 +418,8 @@ class AppmenusExtension(qubes.ext.Extension):
@qubes.ext.handler('property-set:internal') @qubes.ext.handler('property-set:internal')
def on_property_set_internal(self, vm, event, prop, newvalue, *args): def on_property_set_internal(self, vm, event, prop, newvalue, *args):
if not os.path.exists(vm.dir_path):
return
if len(args): if len(args):
oldvalue = args[0] oldvalue = args[0]
else: else:
@ -423,6 +431,8 @@ class AppmenusExtension(qubes.ext.Extension):
@qubes.ext.handler('backup-get-files') @qubes.ext.handler('backup-get-files')
def files_for_backup(self, vm, event): def files_for_backup(self, vm, event):
if not os.path.exists(vm.dir_path):
return
if vm.internal: if vm.internal:
return return
if vm.updateable: if vm.updateable: