Changeset View
Changeset View
Standalone View
Standalone View
swh/fuse/fs/mountpoint.py
| Show First 20 Lines • Show All 170 Lines • ▼ Show 20 Lines | class ArtifactShardBySwhid(FuseDirEntry): | ||||
| target=Path(root_path, f"archive/{swhid}"), | target=Path(root_path, f"archive/{swhid}"), | ||||
| ) | ) | ||||
| yield self.create_child( | yield self.create_child( | ||||
| FuseSymlinkEntry, | FuseSymlinkEntry, | ||||
| name=f"{swhid}{JSON_SUFFIX}", | name=f"{swhid}{JSON_SUFFIX}", | ||||
| target=Path(root_path, f"archive/{swhid}{JSON_SUFFIX}"), | target=Path(root_path, f"archive/{swhid}{JSON_SUFFIX}"), | ||||
| ) | ) | ||||
| async def unlink(self, name: str) -> None: | |||||
| try: | |||||
| if name.endswith(JSON_SUFFIX): | |||||
| name = name[: -len(JSON_SUFFIX)] | |||||
| swhid = parse_swhid(name) | |||||
| await self.fuse.cache.metadata.remove(swhid) | |||||
| await self.fuse.cache.blob.remove(swhid) | |||||
| except ValidationError: | |||||
| raise | |||||
| async def compute_entries(self) -> AsyncIterator[FuseEntry]: | async def compute_entries(self) -> AsyncIterator[FuseEntry]: | ||||
| prefixes = set() | prefixes = set() | ||||
| async for swhid in self.fuse.cache.get_cached_swhids(): | async for swhid in self.fuse.cache.get_cached_swhids(): | ||||
| prefixes.add(swhid.object_id[:2]) | prefixes.add(swhid.object_id[:2]) | ||||
| for prefix in prefixes: | for prefix in prefixes: | ||||
| yield self.create_child( | yield self.create_child( | ||||
| CacheDir.ArtifactShardBySwhid, | CacheDir.ArtifactShardBySwhid, | ||||
| name=prefix, | name=prefix, | ||||
| mode=int(EntryMode.RDONLY_DIR), | mode=int(EntryMode.RDWR_DIR), | ||||
| prefix=prefix, | prefix=prefix, | ||||
| ) | ) | ||||
| yield self.create_child( | yield self.create_child( | ||||
| FuseSymlinkEntry, | FuseSymlinkEntry, | ||||
| name=OriginDir.name, | name=OriginDir.name, | ||||
| target=Path(self.get_relative_root_path(), OriginDir.name), | target=Path(self.get_relative_root_path(), OriginDir.name), | ||||
| ) | ) | ||||
| Show All 35 Lines | |||||