From dd69a18dbfb520a58ee3adc8a75043f06029b20e Mon Sep 17 00:00:00 2001 From: Sebastian Goscik Date: Thu, 8 Dec 2022 00:14:08 +0000 Subject: [PATCH] Raise an error when trying to add a video larger than the buffer --- unifi_protect_backup/utils.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/unifi_protect_backup/utils.py b/unifi_protect_backup/utils.py index 0f06ca8..0171c5c 100644 --- a/unifi_protect_backup/utils.py +++ b/unifi_protect_backup/utils.py @@ -160,6 +160,11 @@ class VideoQueue(asyncio.Queue): Put an item into the queue. If the queue is full, wait until a free slot is available before adding item. """ + if len(item[1]) > self._maxsize: + raise ValueError( + f"Item is larger ({human_readable_size(len(item[1]))}) than the size of the buffer ({human_readable_size(self._maxsize)})" + ) + while self.full(item): putter = self._loop.create_future() self._putters.append(putter)