Files
dragonpilot/selfdrive/loggerd/xattr_cache.py
T
Vehicle Researcher 634aa84919 lp-dp 2023-09-13T13:36:48 for EON/C2
version: lp-dp v0.9.5 for EON/C2
date: 2023-09-13T13:36:48
commit: 1d59b81c40b93f37d4a341c5d35b1c3cd293543d
2023-09-13 13:36:57 +08:00

16 lines
593 B
Python

from typing import Dict, Tuple
from openpilot.common.xattr import getxattr as getattr1
from openpilot.common.xattr import setxattr as setattr1
cached_attributes: Dict[Tuple, bytes] = {}
def getxattr(path: str, attr_name: bytes) -> bytes:
if (path, attr_name) not in cached_attributes:
response = getattr1(path, attr_name)
cached_attributes[(path, attr_name)] = response
return cached_attributes[(path, attr_name)]
def setxattr(path: str, attr_name: str, attr_value: bytes) -> None:
cached_attributes.pop((path, attr_name), None)
return setattr1(path, attr_name, attr_value)