mirror of
https://github.com/ep1cman/unifi-protect-backup.git
synced 2025-12-15 07:43:29 +00:00
Refactor upload into its own method
This commit is contained in:
@@ -257,10 +257,18 @@ class UnifiProtectBackup:
|
||||
logger.exception(e)
|
||||
continue
|
||||
|
||||
logger.debug(f"\tSize: {human_readable_size(len(video))}")
|
||||
try:
|
||||
await self._upload_video(video, destination)
|
||||
except RuntimeError:
|
||||
continue
|
||||
|
||||
async def _upload_video(self, video: bytes, destination: pathlib.Path):
|
||||
""" """
|
||||
|
||||
logger.debug(" Uploading video via rclone...")
|
||||
logger.debug(f" To: {destination}")
|
||||
logger.debug(f" Size: {human_readable_size(len(video))}")
|
||||
|
||||
# Upload video
|
||||
logger.debug("\tUploading video via rclone...")
|
||||
cmd = f"rclone rcat -vv '{destination}'"
|
||||
proc = await asyncio.create_subprocess_shell(
|
||||
cmd,
|
||||
@@ -276,7 +284,7 @@ class UnifiProtectBackup:
|
||||
logger.warn("Failed to download video")
|
||||
logger.warn(f"stdout:\n{stdout.decode()}")
|
||||
logger.warn(f"stderr:\n{stderr.decode()}")
|
||||
continue
|
||||
raise RuntimeError()
|
||||
|
||||
logger.info("Backed up successfully!")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user