Remove bug from display manager of missing function
This commit is contained in:
@@ -1811,20 +1811,7 @@ class DisplayManager:
|
|||||||
# Screenshot capture subsystem
|
# Screenshot capture subsystem
|
||||||
# -------------------------------------------------------------
|
# -------------------------------------------------------------
|
||||||
|
|
||||||
def _write_screenshot_meta(self, capture_type: str, final_path: str, send_immediately: bool = False):
|
def _pending_trigger_is_valid(self, meta: Dict) -> bool:
|
||||||
"""Write screenshots/meta.json atomically so simclient can detect new captures.
|
|
||||||
|
|
||||||
IMPORTANT: Protect event-triggered metadata from being overwritten by periodic captures.
|
|
||||||
If a periodic screenshot is captured while an event-triggered one is still pending
|
|
||||||
transmission (send_immediately=True), skip writing meta.json to preserve the event's metadata.
|
|
||||||
|
|
||||||
Args:
|
|
||||||
capture_type: 'periodic', 'event_start', or 'event_stop'
|
|
||||||
final_path: absolute path of the just-written screenshot file
|
|
||||||
send_immediately: True for triggered (event) captures, False for periodic ones
|
|
||||||
"""
|
|
||||||
try:
|
|
||||||
def _pending_trigger_is_valid(meta: Dict) -> bool:
|
|
||||||
"""Return True only for fresh, actionable pending trigger metadata.
|
"""Return True only for fresh, actionable pending trigger metadata.
|
||||||
|
|
||||||
This prevents a stale/corrupt pending flag from permanently blocking
|
This prevents a stale/corrupt pending flag from permanently blocking
|
||||||
@@ -1873,6 +1860,19 @@ class DisplayManager:
|
|||||||
except Exception:
|
except Exception:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
def _write_screenshot_meta(self, capture_type: str, final_path: str, send_immediately: bool = False):
|
||||||
|
"""Write screenshots/meta.json atomically so simclient can detect new captures.
|
||||||
|
|
||||||
|
IMPORTANT: Protect event-triggered metadata from being overwritten by periodic captures.
|
||||||
|
If a periodic screenshot is captured while an event-triggered one is still pending
|
||||||
|
transmission (send_immediately=True), skip writing meta.json to preserve the event's metadata.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
capture_type: 'periodic', 'event_start', or 'event_stop'
|
||||||
|
final_path: absolute path of the just-written screenshot file
|
||||||
|
send_immediately: True for triggered (event) captures, False for periodic ones
|
||||||
|
"""
|
||||||
|
try:
|
||||||
meta_path = os.path.join(self.screenshot_dir, 'meta.json')
|
meta_path = os.path.join(self.screenshot_dir, 'meta.json')
|
||||||
|
|
||||||
# PROTECTION: Don't overwrite pending event-triggered metadata with periodic capture
|
# PROTECTION: Don't overwrite pending event-triggered metadata with periodic capture
|
||||||
@@ -1882,7 +1882,7 @@ class DisplayManager:
|
|||||||
with open(meta_path, 'r', encoding='utf-8') as f:
|
with open(meta_path, 'r', encoding='utf-8') as f:
|
||||||
existing_meta = json.load(f)
|
existing_meta = json.load(f)
|
||||||
# If there's a pending event-triggered capture, skip this periodic write
|
# If there's a pending event-triggered capture, skip this periodic write
|
||||||
if _pending_trigger_is_valid(existing_meta):
|
if self._pending_trigger_is_valid(existing_meta):
|
||||||
logging.debug(f"Skipping periodic meta.json to preserve pending {existing_meta.get('type')} (send_immediately=True)")
|
logging.debug(f"Skipping periodic meta.json to preserve pending {existing_meta.get('type')} (send_immediately=True)")
|
||||||
return
|
return
|
||||||
except Exception:
|
except Exception:
|
||||||
@@ -2105,7 +2105,7 @@ class DisplayManager:
|
|||||||
with open(meta_path, 'r', encoding='utf-8') as f:
|
with open(meta_path, 'r', encoding='utf-8') as f:
|
||||||
existing_meta = json.load(f)
|
existing_meta = json.load(f)
|
||||||
# If there's a pending event-triggered capture, don't update latest.jpg
|
# If there's a pending event-triggered capture, don't update latest.jpg
|
||||||
if _pending_trigger_is_valid(existing_meta):
|
if self._pending_trigger_is_valid(existing_meta):
|
||||||
should_update_latest = False
|
should_update_latest = False
|
||||||
logging.debug(f"Skipping latest.jpg update to preserve pending {existing_meta.get('type')} screenshot")
|
logging.debug(f"Skipping latest.jpg update to preserve pending {existing_meta.get('type')} screenshot")
|
||||||
except Exception:
|
except Exception:
|
||||||
|
|||||||
Reference in New Issue
Block a user