summaryrefslogtreecommitdiffstats
path: root/recording
diff options
context:
space:
mode:
authorDaniel Calviño Sánchez <danxuliu@gmail.com>2023-03-22 00:50:13 +0100
committerDaniel Calviño Sánchez <danxuliu@gmail.com>2023-03-22 00:59:56 +0100
commit6f924dc1df1b7e47876faf8911bded24433532a1 (patch)
treeff801f6965c9811347027a752c45c07c6eff2586 /recording
parent46953fec365892d34030e72ffe1a183e289f99c9 (diff)
Do not notify a failure if the recording is stopped without starting
When the recording is stopped the helpers, like the display or the browser, are stopped. This might cause an exception to be thrown, but if the recording was still starting and it was not fully started yet there is no need to notify that failure to the Nextcloud server. Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
Diffstat (limited to 'recording')
-rw-r--r--recording/src/nextcloud/talk/recording/Service.py17
1 files changed, 16 insertions, 1 deletions
diff --git a/recording/src/nextcloud/talk/recording/Service.py b/recording/src/nextcloud/talk/recording/Service.py
index a3b72b334..802cc6b59 100644
--- a/recording/src/nextcloud/talk/recording/Service.py
+++ b/recording/src/nextcloud/talk/recording/Service.py
@@ -28,7 +28,7 @@ import subprocess
from datetime import datetime
from pyvirtualdisplay import Display
from secrets import token_urlsafe
-from threading import Thread
+from threading import Event, Thread
from . import BackendNotifier
from .Config import config
@@ -169,6 +169,9 @@ class Service:
self.status = status
self.owner = owner
+ self._started = Event()
+ self._stopped = Event()
+
self._display = None
self._audioModuleIndex = None
self._participant = None
@@ -226,6 +229,8 @@ class Service:
self._logger.debug("Joining call")
self._participant.joinCall(self.token)
+ self._started.set()
+
BackendNotifier.started(self.backend, self.token, self.status, actorType, actorId)
extensionlessFileName = f'{fullDirectory}/recording-{datetime.now().strftime("%Y%m%d-%H%M%S")}'
@@ -250,6 +255,14 @@ class Service:
except Exception as exception:
self._stopHelpers()
+ if self._stopped.is_set() and not self._started.is_set():
+ # If the service fails before being started but it was already
+ # stopped the error does not need to be notified; the error was
+ # probably caused by stopping the helpers, and even if it was
+ # something else it does not need to be notified either given
+ # that the recording was not started yet.
+ raise
+
try:
BackendNotifier.failed(self.backend, self.token)
except:
@@ -271,6 +284,8 @@ class Service:
:raise Exception: if the file could not be uploaded.
"""
+ self._stopped.set()
+
self._stopHelpers()
BackendNotifier.stopped(self.backend, self.token, actorType, actorId)