From 19609705fcf12f468df209d319da86492d92e502 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Wed, 25 May 2016 03:28:38 +0200 Subject: [PATCH] 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 --- qubesappmenus/__init__.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/qubesappmenus/__init__.py b/qubesappmenus/__init__.py index 1ca0e9c..9c030ef 100644 --- a/qubesappmenus/__init__.py +++ b/qubesappmenus/__init__.py @@ -298,10 +298,14 @@ class AppmenusExtension(qubes.ext.Extension): @qubes.ext.handler('property-pre-set:name') def pre_rename(self, vm, event, prop, *args): + if not os.path.exists(vm.dir_path): + return self.appmenus_remove(vm) @qubes.ext.handler('property-set:name') def post_rename(self, vm, event, prop, *args): + if not os.path.exists(vm.dir_path): + return self.appmenus_create(vm) @qubes.ext.handler('domain-create-on-disk') @@ -384,6 +388,8 @@ class AppmenusExtension(qubes.ext.Extension): @qubes.ext.handler('property-set:label') def label_setter(self, vm, event, *args): + if not os.path.exists(vm.dir_path): + return self.appicons_create(vm, force=True) # Apparently desktop environments heavily caches the icons, @@ -412,6 +418,8 @@ class AppmenusExtension(qubes.ext.Extension): @qubes.ext.handler('property-set:internal') def on_property_set_internal(self, vm, event, prop, newvalue, *args): + if not os.path.exists(vm.dir_path): + return if len(args): oldvalue = args[0] else: @@ -423,6 +431,8 @@ class AppmenusExtension(qubes.ext.Extension): @qubes.ext.handler('backup-get-files') def files_for_backup(self, vm, event): + if not os.path.exists(vm.dir_path): + return if vm.internal: return if vm.updateable: