fix: limit length of screenshot deque

This commit is contained in:
2026-07-05 17:50:14 +08:00
parent 7d084db107
commit af3e178c88
+8 -1
View File
@@ -98,7 +98,14 @@ class Screenshot(Adb, WSA, DroidCast, AScreenCap, Scrcpy):
@cached_property @cached_property
def screenshot_deque(self): 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 @cached_property
def screenshot_tracking(self): def screenshot_tracking(self):