failed rcat no longer writes to database

This commit is contained in:
Sebastian Goscik
2023-10-31 23:37:52 +00:00
parent dc8473cc3d
commit d5a74f475a

View File

@@ -9,7 +9,14 @@ import aiosqlite
from pyunifiprotect import ProtectApiClient
from pyunifiprotect.data.nvr import Event
from unifi_protect_backup.utils import VideoQueue, get_camera_name, human_readable_size, run_command, setup_event_logger
from unifi_protect_backup.utils import (
VideoQueue,
get_camera_name,
human_readable_size,
run_command,
setup_event_logger,
SubprocessException,
)
class VideoUploader:
@@ -74,10 +81,13 @@ class VideoUploader:
destination = await self._generate_file_path(event)
self.logger.debug(f" Destination: {destination}")
try:
await self._upload_video(video, destination, self._rclone_args)
await self._update_database(event, destination)
self.logger.debug("Uploaded")
except SubprocessException:
self.logger.error(f" Failed to upload file: '{destination}'")
self.current_event = None
except Exception as e:
@@ -99,7 +109,7 @@ class VideoUploader:
"""
returncode, stdout, stderr = await run_command(f'rclone rcat -vv {rclone_args} "{destination}"', video)
if returncode != 0:
self.logger.error(f" Failed to upload file: '{destination}'")
raise SubprocessException(stdout, stderr, returncode)
async def _update_database(self, event: Event, destination: str):
"""Add the backed up event to the database along with where it was backed up to."""