Fix: [ALAS] Limit the length of screenshot deque

This commit is contained in:
LmeSzinc 2024-01-01 22:15:40 +08:00
parent 85ce412fb5
commit 21a8e276b6

View File

@ -98,7 +98,14 @@ class Screenshot(Adb, WSA, DroidCast, AScreenCap, Scrcpy):
@cached_property
def screenshot_deque(self):
return deque(maxlen=int(self.config.Error_ScreenshotLength))
try:
length = int(self.config.Error_ScreenshotLength)
except ValueError:
logger.error(f'Error_ScreenshotLength={self.config.Error_ScreenshotLength} is not an integer')
raise RequestHumanTakeover
# Limit in 1~300
length = max(1, min(length, 300))
return deque(maxlen=length)
@cached_property
def screenshot_tracking(self):