Skip to contentSkip to conversation

tinfoil: Disable data tracking also when the operation fails

PATCH New Stefano Tondo 1 participant 1 message Nov 23

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tinfoil: Disable data tracking also when the operation fails

From: Stefano Tondo <[email protected]>

_data_tracked_if_enabled() enables data tracking before the operation and disables it after the operation. If the operation raises an exception, the second step does not run and tracking stays enabled in the server for the rest of the tinfoil session.

Disable tracking in a finally block.

---
 lib/bb/tinfoil.py | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
lib/bb/tinfoil.py +5 -4
index 9b9925e51..4fd2a9af8 100644
@@ -789,10 +789,11 @@ class Tinfoil:
             self.run_command('enableDataTracking')
 
         # Here goes the operation with the optional data tracking
-        yield
-
-        if self.tracking:
-            self.run_command('disableDataTracking')
+        try:
+            yield
+        finally:
+            if self.tracking:
+                self.run_command('disableDataTracking')
 
     def finalizeData(self):
         """
Signature · 1 line
2.56.1