From 58065ed78c29e4b980daf21f324239e80f43c53b Mon Sep 17 00:00:00 2001 From: Franoosh Date: Thu, 18 Jun 2026 07:54:20 +0200 Subject: worker.py: - wrap timestamp string creation in a try/except - add creating timestamp string from current time as a fallback --- worker.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'worker.py') diff --git a/worker.py b/worker.py index 2e1bb6c..18901ce 100644 --- a/worker.py +++ b/worker.py @@ -230,10 +230,14 @@ class ServerWorker(Thread): """ update_clients(client_id, camera_id) - timestamp_string = datetime.datetime.fromtimestamp( - struct.unpack('d', timestamp)[0] - ).strftime(TIME_FORMAT_STRING) - logger.debug("Timestamp string: %r", timestamp_string) + try: + timestamp_string = datetime.datetime.fromtimestamp( + struct.unpack('d', timestamp)[0] + ).strftime(TIME_FORMAT_STRING) + logger.debug("Timestamp string: %r", timestamp_string) + except Exception as exc: + logger.error("Error unpacking timestamp: %r, creating from current time!", exc) + timestamp_string = datetime.datetime.now().strftime(TIME_FORMAT_STRING) # If it's ok to use current time as fallback, why send timestamp in the first place? camera_id_string = camera_id.decode('utf-8') filename = f"{camera_id_string}-{timestamp_string}.mp4" -- cgit v1.3