Changeset View
Changeset View
Standalone View
Standalone View
swh/fuse/cache.py
Show First 20 Lines • Show All 208 Lines • ▼ Show 20 Lines | async def get(self, swhid: SWHID) -> Optional[List[SWHID]]: | ||||
try: | try: | ||||
history.append(parse_swhid(parent)) | history.append(parse_swhid(parent)) | ||||
except ValidationError: | except ValidationError: | ||||
logging.warning(f"Cannot parse object from history cache: {parent}") | logging.warning(f"Cannot parse object from history cache: {parent}") | ||||
return history | return history | ||||
async def set(self, history: str) -> None: | async def set(self, history: str) -> None: | ||||
history = history.strip() | history = history.strip() | ||||
if history: | |||||
edges = [edge.split(" ") for edge in history.split("\n")] | edges = [edge.split(" ") for edge in history.split("\n")] | ||||
await self.conn.executemany( | await self.conn.executemany( | ||||
"insert or ignore into history_graph values (?, ?)", edges | "insert or ignore into history_graph values (?, ?)", edges | ||||
) | ) | ||||
await self.conn.commit() | await self.conn.commit() | ||||
class DirEntryCache: | class DirEntryCache: | ||||
""" The direntry cache map inode representing directories to the entries | """ The direntry cache map inode representing directories to the entries | ||||
they contain. Each entry comes with its name as well as file attributes | they contain. Each entry comes with its name as well as file attributes | ||||
(i.e., all its needed to perform a detailed directory listing). | (i.e., all its needed to perform a detailed directory listing). | ||||
Additional attributes of each directory entry should be looked up on a entry | Additional attributes of each directory entry should be looked up on a entry | ||||
▲ Show 20 Lines • Show All 62 Lines • Show Last 20 Lines |