Changeset View
Changeset View
Standalone View
Standalone View
swh/fuse/fuse.py
| Show First 20 Lines • Show All 303 Lines • ▼ Show 20 Lines | ) -> pyfuse3.EntryAttributes: | ||||
| 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) | ||||
| self.logger.debug("readlink(name=%s, inode=%d)", entry.name, inode) | self.logger.debug("readlink(name=%s, inode=%d)", entry.name, inode) | ||||
| assert isinstance(entry, FuseSymlinkEntry) | assert isinstance(entry, FuseSymlinkEntry) | ||||
| return os.fsencode(entry.get_target()) | return os.fsencode(entry.get_target()) | ||||
| async def unlink( | |||||
| self, parent_inode: int, name: str, _ctx: pyfuse3.RequestContext | |||||
| ) -> None: | |||||
| """ Remove a file """ | |||||
| name = os.fsdecode(name) | |||||
| parent_entry = self.inode2entry(parent_inode) | |||||
| self.logger.debug( | |||||
| "unlink(parent_name=%s, parent_inode=%d, name=%s)", | |||||
| parent_entry.name, | |||||
| parent_inode, | |||||
| name, | |||||
| ) | |||||
| try: | |||||
| await parent_entry.unlink(name) | |||||
| except Exception as err: | |||||
| self.logger.exception("Cannot unlink: %s", err) | |||||
zack: don't you need to also raise a `FUSEError` here, in case of exception? or am I missing the… | |||||
Not Done Inline ActionsUhm, i'm not super-happy about always raising ENOENT in case of errors, as there might be other failure reasons, but looking around I see it's a common pattern also for other methods. So adding another instance won't make it worse. zack: Uhm, i'm not super-happy about always raising ENOENT in case of errors, as there might be other… | |||||
| 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 """ | ||||
| # Use pyfuse3 asyncio layer to match the rest of Software Heritage codebase | # Use pyfuse3 asyncio layer to match the rest of Software Heritage codebase | ||||
| pyfuse3_asyncio.enable() | pyfuse3_asyncio.enable() | ||||
| async with FuseCache(conf["cache"]) as cache: | async with FuseCache(conf["cache"]) as cache: | ||||
| Show All 20 Lines | |||||
don't you need to also raise a FUSEError here, in case of exception? or am I missing the reason why it's not needed?