Skip to content

Commit 9e90632

Browse files
committed
Refactor: storage.py need now use AsyncDbSession
1 parent 947cca2 commit 9e90632

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

src/aleph/storage.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
from aleph.services.ipfs.common import get_cid_version
2323
from aleph.services.p2p.http import request_hash as p2p_http_request_hash
2424
from aleph.services.storage.engine import StorageEngine
25-
from aleph.types.db_session import DbSession
25+
from aleph.types.db_session import AsyncDbSession
2626
from aleph.types.files import FileType
2727
from aleph.utils import get_sha256
2828

@@ -251,7 +251,7 @@ async def pin_hash(self, chash: str, timeout: int = 30, tries: int = 1):
251251
await self.ipfs_service.pin_add(cid=chash, timeout=timeout, tries=tries)
252252

253253
async def add_json(
254-
self, session: DbSession, value: Any, engine: ItemType = ItemType.ipfs
254+
self, session: AsyncDbSession, value: Any, engine: ItemType = ItemType.ipfs
255255
) -> str:
256256
content = aleph_json.dumps(value)
257257

@@ -263,7 +263,7 @@ async def add_json(
263263
raise NotImplementedError("storage engine %s not supported" % engine)
264264

265265
await self.storage_engine.write(filename=chash, content=content)
266-
upsert_file(
266+
await upsert_file(
267267
session=session,
268268
file_hash=chash,
269269
size=len(content),
@@ -273,18 +273,21 @@ async def add_json(
273273
return chash
274274

275275
async def add_file_content_to_local_storage(
276-
self, session: DbSession, file_content: bytes, file_hash: str
276+
self, session: AsyncDbSession, file_content: bytes, file_hash: str
277277
) -> None:
278278
await self.storage_engine.write(filename=file_hash, content=file_content)
279-
upsert_file(
279+
await upsert_file(
280280
session=session,
281281
file_hash=file_hash,
282282
size=len(file_content),
283283
file_type=FileType.FILE,
284284
)
285285

286286
async def add_file(
287-
self, session: DbSession, file_content: bytes, engine: ItemType = ItemType.ipfs
287+
self,
288+
session: AsyncDbSession,
289+
file_content: bytes,
290+
engine: ItemType = ItemType.ipfs,
288291
) -> str:
289292
if engine == ItemType.ipfs:
290293
output = await self.ipfs_service.add_file(file_content)

0 commit comments

Comments
 (0)