Skip to content
This repository has been archived by the owner on May 24, 2024. It is now read-only.

Commit

Permalink
Use piece_cid.car as output filename
Browse files Browse the repository at this point in the history
  • Loading branch information
liuziba committed Jul 1, 2022
1 parent 2da2ec3 commit ba7ee3d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
8 changes: 4 additions & 4 deletions generate-car.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,6 @@ func main() {
if err != nil {
return err
}
err = os.Rename(outPath, path.Join(outDir, cid+".car"))
if err != nil {
return err
}
rawCommP, pieceSize, err := cp.Digest()
if err != nil {
return err
Expand All @@ -153,6 +149,10 @@ func main() {
if err != nil {
return err
}
err = os.Rename(outPath, path.Join(outDir, commCid.String()+".car"))
if err != nil {
return err
}
output, err := json.Marshal(Result{
Ipld: ipld,
DataCid: cid,
Expand Down
16 changes: 8 additions & 8 deletions spec/generate-car_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
result = JSON.parse(stdout)
expectDataCid = JSON.parse(expectIpld)['Hash']
expect(result['DataCid']).to eq(expectDataCid)
streamCommpResult = `cat test/#{expectDataCid}.car | ~/go/bin/stream-commp 2>&1`
streamCommpResult = `cat test/#{result['PieceCid']}.car | ~/go/bin/stream-commp 2>&1`
expectCommp = streamCommpResult.lines.find{|line|line.include?'CommPCid'}.strip.split(' ')[1]
expectPieceSize = streamCommpResult.lines.find{|line|line.include?'Padded piece'}.strip.split(' ')[-2].to_i
expect(result['PieceCid']).to eq(expectCommp)
Expand Down Expand Up @@ -63,7 +63,7 @@
result = JSON.parse(stdout)
expectDataCid = JSON.parse(expectIpld)['Hash']
expect(result['DataCid']).to eq(expectDataCid)
streamCommpResult = `cat test/#{expectDataCid}.car | ~/go/bin/stream-commp 2>&1`
streamCommpResult = `cat test/#{result['PieceCid']}.car | ~/go/bin/stream-commp 2>&1`
expectCommp = streamCommpResult.lines.find{|line|line.include?'CommPCid'}.strip.split(' ')[1]
expectPieceSize = streamCommpResult.lines.find{|line|line.include?'Padded piece'}.strip.split(' ')[-2].to_i
expect(result['PieceCid']).to eq(expectCommp)
Expand Down Expand Up @@ -93,7 +93,7 @@
result = JSON.parse(stdout)
expectDataCid = JSON.parse(expectIpld)['Hash']
expect(result['DataCid']).to eq(expectDataCid)
streamCommpResult = `cat test/#{expectDataCid}.car | ~/go/bin/stream-commp 2>&1`
streamCommpResult = `cat test/#{result['PieceCid']}.car | ~/go/bin/stream-commp 2>&1`
expectCommp = streamCommpResult.lines.find{|line|line.include?'CommPCid'}.strip.split(' ')[1]
expectPieceSize = streamCommpResult.lines.find{|line|line.include?'Padded piece'}.strip.split(' ')[-2].to_i
expect(result['PieceCid']).to eq(expectCommp)
Expand Down Expand Up @@ -129,7 +129,7 @@
result = JSON.parse(stdout)
expectDataCid = JSON.parse(expectIpld)['Hash']
expect(result['DataCid']).to eq(expectDataCid)
streamCommpResult = `cat test/#{expectDataCid}.car | ~/go/bin/stream-commp 2>&1`
streamCommpResult = `cat test/#{result['PieceCid']}.car | ~/go/bin/stream-commp 2>&1`
expectCommp = streamCommpResult.lines.find{|line|line.include?'CommPCid'}.strip.split(' ')[1]
expectPieceSize = streamCommpResult.lines.find{|line|line.include?'Padded piece'}.strip.split(' ')[-2].to_i
expect(result['PieceCid']).to eq(expectCommp)
Expand Down Expand Up @@ -158,7 +158,7 @@
result = JSON.parse(stdout)
expectDataCid = JSON.parse(expectIpld)['Hash']
expect(result['DataCid']).to eq(expectDataCid)
streamCommpResult = `cat test/#{expectDataCid}.car | ~/go/bin/stream-commp 2>&1`
streamCommpResult = `cat test/#{result['PieceCid']}.car | ~/go/bin/stream-commp 2>&1`
expectCommp = streamCommpResult.lines.find{|line|line.include?'CommPCid'}.strip.split(' ')[1]
expectPieceSize = streamCommpResult.lines.find{|line|line.include?'Padded piece'}.strip.split(' ')[-2].to_i
expect(result['PieceCid']).to eq(expectCommp)
Expand Down Expand Up @@ -187,7 +187,7 @@
result = JSON.parse(stdout)
expectDataCid = JSON.parse(expectIpld)['Hash']
expect(result['DataCid']).to eq(expectDataCid)
streamCommpResult = `cat test/#{expectDataCid}.car | ~/go/bin/stream-commp 2>&1`
streamCommpResult = `cat test/#{result['PieceCid']}.car | ~/go/bin/stream-commp 2>&1`
expectCommp = streamCommpResult.lines.find{|line|line.include?'CommPCid'}.strip.split(' ')[1]
expectPieceSize = streamCommpResult.lines.find{|line|line.include?'Padded piece'}.strip.split(' ')[-2].to_i
expect(result['PieceCid']).to eq(expectCommp)
Expand All @@ -214,7 +214,7 @@
result = JSON.parse(stdout)
expectDataCid = JSON.parse(expectIpld)['Hash']
expect(result['DataCid']).to eq(expectDataCid)
streamCommpResult = `cat test/#{expectDataCid}.car | ~/go/bin/stream-commp 2>&1`
streamCommpResult = `cat test/#{result['PieceCid']}.car | ~/go/bin/stream-commp 2>&1`
expectCommp = streamCommpResult.lines.find{|line|line.include?'CommPCid'}.strip.split(' ')[1]
expectPieceSize = streamCommpResult.lines.find{|line|line.include?'Padded piece'}.strip.split(' ')[-2].to_i
expect(result['PieceCid']).to eq(expectCommp)
Expand Down Expand Up @@ -379,7 +379,7 @@
result = JSON.parse(stdout)
expectDataCid = JSON.parse(expectIpld)['Hash']
expect(result['DataCid']).to eq(expectDataCid)
streamCommpResult = `cat test/#{expectDataCid}.car | ~/go/bin/stream-commp 2>&1`
streamCommpResult = `cat test/#{result['PieceCid']}.car | ~/go/bin/stream-commp 2>&1`
expectCommp = streamCommpResult.lines.find{|line|line.include?'CommPCid'}.strip.split(' ')[1]
expectPieceSize = streamCommpResult.lines.find{|line|line.include?'Padded piece'}.strip.split(' ')[-2].to_i
expect(result['PieceCid']).to eq(expectCommp)
Expand Down

0 comments on commit ba7ee3d

Please sign in to comment.