mirror of
https://github.com/ep1cman/unifi-protect-backup.git
synced 2025-12-24 04:04:44 +00:00
Add a storage quota purger
This commit is contained in:
@@ -4,6 +4,7 @@ import logging
|
||||
import pathlib
|
||||
import re
|
||||
from datetime import datetime
|
||||
import asyncio
|
||||
|
||||
import aiosqlite
|
||||
from uiprotect import ProtectApiClient
|
||||
@@ -34,6 +35,7 @@ class VideoUploader:
|
||||
file_structure_format: str,
|
||||
db: aiosqlite.Connection,
|
||||
color_logging: bool,
|
||||
upload_signal: asyncio.Event,
|
||||
):
|
||||
"""Init.
|
||||
|
||||
@@ -45,6 +47,7 @@ class VideoUploader:
|
||||
file_structure_format (str): format string for how to structure the uploaded files
|
||||
db (aiosqlite.Connection): Async SQlite database connection
|
||||
color_logging (bool): Whether or not to add color to logging output
|
||||
upload_signal (asyncio.Event): Set by the uploader to signal an upload has occured
|
||||
"""
|
||||
self._protect: ProtectApiClient = protect
|
||||
self.upload_queue: VideoQueue = upload_queue
|
||||
@@ -53,6 +56,7 @@ class VideoUploader:
|
||||
self._file_structure_format: str = file_structure_format
|
||||
self._db: aiosqlite.Connection = db
|
||||
self.current_event = None
|
||||
self._upload_signal = upload_signal
|
||||
|
||||
self.base_logger = logging.getLogger(__name__)
|
||||
setup_event_logger(self.base_logger, color_logging)
|
||||
@@ -84,6 +88,7 @@ class VideoUploader:
|
||||
try:
|
||||
await self._upload_video(video, destination, self._rclone_args)
|
||||
await self._update_database(event, destination)
|
||||
self._upload_signal.set()
|
||||
self.logger.debug("Uploaded")
|
||||
except SubprocessException:
|
||||
self.logger.error(f" Failed to upload file: '{destination}'")
|
||||
|
||||
Reference in New Issue
Block a user