Skip to content

Commit

Permalink
fix reading
Browse files Browse the repository at this point in the history
  • Loading branch information
anjor committed Oct 20, 2024
1 parent 2ea996c commit c1f6913
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions cmd-car-split.go
Original file line number Diff line number Diff line change
Expand Up @@ -652,10 +652,18 @@ func getSlotAndSizeFromURL(url string) (int64, int64, error) {
if index == -1 {
return 0, 0, fmt.Errorf("CID block not found in the last 2MiB of the file")
}
blockData := partialContent[index:]
blockData := partialContent[index-2:]
r := bufio.NewReader(bytes.NewBuffer(blockData))
cid, _, data, err := carreader.ReadNodeInfoWithData(r)
if err != nil {
return 0, 0, fmt.Errorf("failed to read node info: %w", err)
}
if cid != rootCID {
return 0, 0, fmt.Errorf("expected CID %s, got %s", rootCID, cid)
}

// Decode the Subset
subset, err := iplddecoders.DecodeSubset(blockData)
subset, err := iplddecoders.DecodeSubset(data)
if err != nil {
return 0, 0, fmt.Errorf("failed to decode Subset from block: %w", err)
}
Expand Down

0 comments on commit c1f6913

Please sign in to comment.