temporary fixes to accommodate PR1179

This commit is contained in:
Marcin Czenko 2025-04-27 03:11:23 +02:00
parent 5def89126f
commit 0002bb3298
No known key found for this signature in database
GPG Key ID: 33DEA0C8E30937C0
2 changed files with 122 additions and 108 deletions

View File

@ -23,7 +23,6 @@ import pkg/stew/byteutils
import ../node
import ../logutils
import ../utils/iter
import ../utils/safeasynciter
import ../utils/trackedfutures
import ../errors
import ../manifest
@ -89,6 +88,9 @@ proc createEntryHeader(
proc fetchTarball(
self: DirectoryDownloader, cid: Cid, basePath = ""
): Future[?!void] {.async: (raises: [CancelledError]).} =
# we only need try/catch here because PR for checked exceptions is
# not yet merged
try:
echo "fetchTarball: ", cid, " basePath = ", basePath
# we got a Cid - let's check if this is a manifest (can be either
# a directory or file manifest)
@ -103,8 +105,9 @@ proc fetchTarball(
# get the manifest
without blk =? await self.node.blockStore.getBlock(cid), err:
error "Error retrieving manifest block", cid, err = err.msg
return
failure("Error retrieving manifest block (cid = " & $cid & "), err = " & err.msg)
return failure(
"Error retrieving manifest block (cid = " & $cid & "), err = " & err.msg
)
without manifest =? Manifest.decode(blk), err:
info "Unable to decode as manifest - trying to decode as directory manifest",
@ -160,9 +163,7 @@ proc fetchTarball(
self.printQueue()
var contentLength = 0
proc onBatch(
blocks: seq[Block]
): Future[?!void] {.async: (raises: [CancelledError]).} =
proc onBatch(blocks: seq[Block]): Future[?!void] {.async.} =
echo "onBatch: ", blocks.len, " blocks"
for blk in blocks:
echo "onBatch[blk.data]: ", string.fromBytes(blk.data)
@ -198,6 +199,11 @@ proc fetchTarball(
self.printQueue()
echo "fetchTarball: ", cid, " basePath = ", basePath, " done"
return success()
except CancelledError as e:
raise e
except CatchableError as e:
error "Error fetching tarball", cid, err = e.msg
return failure("Error fetching tarball (cid = " & $cid & "), err = " & e.msg)
proc streamDirectory(
self: DirectoryDownloader, cid: Cid

View File

@ -21,6 +21,9 @@ proc fetchDirectoryManifest*(
## Fetch and decode a manifest block
##
# we only need try/catch here because PR for checked exceptions is
# not yet merged
try:
if err =? cid.isManifest.errorOption:
return failure "CID has invalid content type for manifest {$cid}"
@ -38,7 +41,12 @@ proc fetchDirectoryManifest*(
trace "Decoded directory manifest", cid
manifest.success
return manifest.success
except CancelledError as e:
raise e
except CatchableError as e:
trace "Error fetching directory manifest", cid, err = e.msg
return failure(e.msg)
proc storeDirectoryManifest*(
self: CodexNodeRef, manifest: DirectoryManifest