From da892401dd3b76f61247cf3b69beba1d327ae0f6 Mon Sep 17 00:00:00 2001 From: Disassembler Date: Sun, 26 Apr 2020 17:16:41 +0200 Subject: [PATCH] Don't duplicate existing container records during app update, closes #4 --- usr/lib/python3.8/spoc/app.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/usr/lib/python3.8/spoc/app.py b/usr/lib/python3.8/spoc/app.py index 88563fe..ef7ae0b 100644 --- a/usr/lib/python3.8/spoc/app.py +++ b/usr/lib/python3.8/spoc/app.py @@ -109,8 +109,9 @@ class App: def update(self, observer=None): # Remove containers - for container in self.containers: + for container in self.containers.copy(): container.destroy() + self.containers.remove(container) # Load online definition definition = repo_online.get_app(self.name) self.version = definition['version'] @@ -119,7 +120,13 @@ class App: for container,container_defintion in definition['containers'].items(): self.create_container(container, container_defintion) # Run update script and re-register the app - self.run_script('update') + try: + self.run_script('update') + except: + # Stop all containers if update.sh fails + for container in self.containers: + container.stop() + raise repo_local.register_app(self.name, self.get_definition()) def uninstall(self, observer=None):