Skip to content

Commit

Permalink
return digest of root directory from ComputeOutputsToUpload (#143)
Browse files Browse the repository at this point in the history
This is to make GetTree to CAS work for root directory digest when
upload chunkers returned from ComputeOutputsToUpload
  • Loading branch information
atetubou authored Jun 30, 2020
1 parent 0111bbc commit 9519995
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 6 additions & 1 deletion go/pkg/tree/tree.go
Original file line number Diff line number Diff line change
Expand Up @@ -378,11 +378,16 @@ func ComputeOutputsToUpload(execRoot string, paths []string, chunkSize int, cach
if err != nil {
return nil, nil, err
}
ch, err := chunker.NewFromProto(rootDir, chunkSize)
if err != nil {
return nil, nil, err
}
outs[ch.Digest()] = ch
treePb.Root = rootDir
for _, c := range childDirs {
treePb.Children = append(treePb.Children, c)
}
ch, err := chunker.NewFromProto(treePb, chunkSize)
ch, err = chunker.NewFromProto(treePb, chunkSize)
if err != nil {
return nil, nil, err
}
Expand Down
2 changes: 2 additions & 0 deletions go/pkg/tree/tree_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1251,6 +1251,8 @@ func TestComputeOutputsToUploadDirectories(t *testing.T) {
t.Fatalf("ComputeOutputsToUpload(...) tree proto with digest %+v not uploaded", dg)
}
wantBlobs[dg] = treeBlob
rootBlob := mustMarshal(tc.wantTreeRoot)
wantBlobs[digest.NewFromBlob(rootBlob)] = rootBlob
if diff := cmp.Diff(wantBlobs, gotBlobs); diff != "" {
t.Errorf("ComputeOutputsToUpload(...) gave diff (-want +got) on blobs:\n%s", diff)
}
Expand Down

0 comments on commit 9519995

Please sign in to comment.