Skip to content

Commit

Permalink
sia: fix offsets
Browse files Browse the repository at this point in the history
  • Loading branch information
n8maninger committed Nov 23, 2023
1 parent a5a7eed commit 39bc69e
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions sia/uploader.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,21 @@ func (ufs *UnixFileUploader) Add(ctx context.Context, node format.Node) error {
return err
}

var links []Link
for _, link := range node.Links() {
links = append(links, Link{
CID: link.Cid,
Name: link.Name,
Size: link.Size,
})
}

dataSize := uint64(len(data))
fileSize := ufs.fileSize + dataSize
dataOffset := ufs.dataOffset + dataSize - fileSize
dataOffset := ufs.dataOffset
if dataSize == 0 {
dataOffset = 0
}

ufs.log.Debug("adding node",
zap.Stringer("cid", node.Cid()),
Expand All @@ -115,15 +127,6 @@ func (ufs *UnixFileUploader) Add(ctx context.Context, node format.Node) error {
return fmt.Errorf("failed to write data: %w", err)
}

var links []Link
for _, link := range node.Links() {
links = append(links, Link{
CID: link.Cid,
Name: link.Name,
Size: link.Size,
})
}

block := Block{
CID: node.Cid(),
Links: links,
Expand Down

0 comments on commit 39bc69e

Please sign in to comment.