mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-11-08 13:33:42 +08:00
e52e1a6a86
Implement Sentry scanning, notification state and worker cancellation through explicit policies and preferences.
15 lines
687 B
Python
15 lines
687 B
Python
"""One validated, exact-source saved Sentry document replacement."""
|
|
|
|
from collections.abc import Callable
|
|
|
|
from openpilot.starpilot.saved_document import WriteResult, commit_exact
|
|
from openpilot.starpilot.sentry_mode.preferences import KEY, MAX_BYTES, decode, encode
|
|
|
|
|
|
def commit(params, raw: bytes, expected: bytes | None, authorized: Callable[[], bool]) -> WriteResult:
|
|
preferences = decode(raw) if type(raw) is bytes else None
|
|
if preferences is None or encode(preferences) != raw:
|
|
return WriteResult(False, False)
|
|
return commit_exact(params, key=KEY, max_bytes=MAX_BYTES, raw=raw, expected=expected,
|
|
authorized=authorized, temp_prefix=".tmp_sentry_")
|