]> git.ipfire.org Git - pbs.git/commitdiff
builds: Fix exception when trying to remove a user which is not a watcher
authorMichael Tremer <michael.tremer@ipfire.org>
Mon, 17 Oct 2022 15:37:57 +0000 (15:37 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Mon, 17 Oct 2022 15:37:57 +0000 (15:37 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/buildservice/builds.py
tests/build.py

index 37e9acf6b6b2eccecf0cc00fb25e9725680ecd7b..e3535609d2dc33bdafd6e626712a9f8e0f58642c 100644 (file)
@@ -585,7 +585,10 @@ class Build(base.DataObject):
                )
 
                # Remove from cache
-               self.watchers.remove(user)
+               try:
+                       self.watchers.remove(user)
+               except KeyError:
+                       pass
 
        def _add_watchers(self):
                """
index de159b241967a288a632f2ba814a2700d9bf1500..baf97d65157da218d9eae86bb324013ca726132d 100755 (executable)
@@ -60,6 +60,10 @@ class BuildTestCase(test.TestCase):
                with self.db.transaction():
                        build.remove_watcher(self.user)
 
+               # Remove the default user as watcher (again)
+               with self.db.transaction():
+                       build.remove_watcher(self.user)
+
                # Check if the watcher has been removed
                self.assertNotIn(self.user, build.watchers)