diff --git a/swh/fuse/fuse.py b/swh/fuse/fuse.py --- a/swh/fuse/fuse.py +++ b/swh/fuse/fuse.py @@ -18,7 +18,8 @@ from swh.fuse.cache import FuseCache from swh.fuse.fs.entry import FuseEntry from swh.fuse.fs.mountpoint import Root -from swh.model.identifiers import CONTENT, SWHID +from swh.model.exceptions import ValidationError +from swh.model.identifiers import CONTENT, SWHID, parse_swhid from swh.web.client.client import WebAPIClient @@ -190,8 +191,21 @@ attr = await self.get_attrs(entry) return attr - logging.error(f"Unknown name during lookup: '{name}'") - raise pyfuse3.FUSEError(errno.ENOENT) + # Artifacts can be mounted on the fly, so try to parse it as a SWHID + try: + swhid = parse_swhid(name) + # Prevent infinite loop (see comment below about the recursive call) + # in case we try to lookup a valid SWHID inside an already existing + # artifact (hence not loading a new SWHID on the fly) + if await self.cache.metadata.get(swhid): + raise LookupError + else: + # Load the SWHID in cache and retry the lookup + await self.get_metadata(swhid) + return await self.lookup(parent_inode, name, _ctx) + except (ValidationError, LookupError) as e: + logging.error(f"Unknown name during lookup: '{name}'. Error: {e}") + raise pyfuse3.FUSEError(errno.ENOENT) async def readlink(self, inode: int, _ctx: pyfuse3.RequestContext) -> bytes: entry = self.inode2entry(inode)