Changeset View
Changeset View
Standalone View
Standalone View
swh/fuse/fuse.py
Show First 20 Lines • Show All 178 Lines • ▼ Show 20 Lines | class Fuse(pyfuse3.Operations): | ||||
async def lookup( | async def lookup( | ||||
self, parent_inode: int, name: str, _ctx: pyfuse3.RequestContext | self, parent_inode: int, name: str, _ctx: pyfuse3.RequestContext | ||||
) -> pyfuse3.EntryAttributes: | ) -> pyfuse3.EntryAttributes: | ||||
""" Look up a directory entry by name and get its attributes """ | """ Look up a directory entry by name and get its attributes """ | ||||
name = os.fsdecode(name) | name = os.fsdecode(name) | ||||
parent_entry = self.inode2entry(parent_inode) | parent_entry = self.inode2entry(parent_inode) | ||||
lookup_entry = await parent_entry.lookup(name) | |||||
async for entry in parent_entry: | if lookup_entry: | ||||
if name == entry.name: | return await self.get_attrs(lookup_entry) | ||||
attr = await self.get_attrs(entry) | else: | ||||
return attr | |||||
logging.error(f"Unknown name during lookup: '{name}'") | logging.error(f"Unknown name during lookup: '{name}'") | ||||
raise pyfuse3.FUSEError(errno.ENOENT) | raise pyfuse3.FUSEError(errno.ENOENT) | ||||
async def readlink(self, inode: int, _ctx: pyfuse3.RequestContext) -> bytes: | async def readlink(self, inode: int, _ctx: pyfuse3.RequestContext) -> bytes: | ||||
entry = self.inode2entry(inode) | entry = self.inode2entry(inode) | ||||
return os.fsencode(entry.get_target()) | return os.fsencode(entry.get_target()) | ||||
async def main(swhids: List[SWHID], root_path: Path, conf: Dict[str, Any]) -> None: | async def main(swhids: List[SWHID], root_path: Path, conf: Dict[str, Any]) -> None: | ||||
""" swh-fuse CLI entry-point """ | """ swh-fuse CLI entry-point """ | ||||
Show All 21 Lines |