mirror of
https://github.com/logos-storage/logos-storage-nim.git
synced 2026-01-05 23:13:09 +00:00
temporary fixes to accommodate PR1179
This commit is contained in:
parent
5def89126f
commit
0002bb3298
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user