Changeset View
Changeset View
Standalone View
Standalone View
swh/fuse/fs/artifact.py
Show All 33 Lines | class Content(ArtifactEntry): | ||||
Note that permissions are associated to blobs only in the context of | Note that permissions are associated to blobs only in the context of | ||||
directories. Hence, when accessing blobs from the top-level `archive/` | directories. Hence, when accessing blobs from the top-level `archive/` | ||||
directory, the permissions of the `archive/SWHID` file will be arbitrary and | directory, the permissions of the `archive/SWHID` file will be arbitrary and | ||||
not meaningful (e.g., `0x644`). """ | not meaningful (e.g., `0x644`). """ | ||||
async def get_content(self) -> bytes: | async def get_content(self) -> bytes: | ||||
data = await self.fuse.get_blob(self.swhid) | data = await self.fuse.get_blob(self.swhid) | ||||
self.prefetch["length"] = len(data) | if not self.prefetch: | ||||
self.prefetch = {"length": len(data)} | |||||
return data | return data | ||||
async def size(self) -> int: | async def size(self) -> int: | ||||
if self.prefetch: | if self.prefetch: | ||||
return self.prefetch["length"] | return self.prefetch["length"] | ||||
else: | else: | ||||
return len(await self.get_content()) | return len(await self.get_content()) | ||||
▲ Show 20 Lines • Show All 128 Lines • Show Last 20 Lines |