Files
dragonpilot/selfdrive/loggerd/xattr_cache.py
Dragonpilot Team ea800c8f74 dragonpilot 2023-03-27T06:11:06 for EON/C2
version: dragonpilot v0.9.2 beta for EON/C2
date: 2023-03-27T06:11:06
dp-dev(priv2) master commit: 0a08aa2b73a505e11e4c98ac6c5989464b7d339f
2023-03-27 06:27:07 +00:00

16 lines
573 B
Python

from typing import Dict, Tuple
from common.xattr import getxattr as getattr1
from 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)