Skip to content

Commit

Permalink
storage: use the new ApplyStagedLayer interface
Browse files Browse the repository at this point in the history
Signed-off-by: Giuseppe Scrivano <[email protected]>
  • Loading branch information
giuseppe committed Feb 16, 2024
1 parent dcb71b6 commit cd36ca2
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions storage/storage_dest.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ func (s *storageImageDestination) Close() error {
}
for _, v := range s.lockProtected.diffOutputs {
if v.Target != "" {
_ = s.imageRef.transport.store.CleanupStagingDirectory(v.Target)
_ = s.imageRef.transport.store.CleanupStagedLayer(v)
}
}
return os.RemoveAll(s.directory)
Expand Down Expand Up @@ -770,11 +770,6 @@ func (s *storageImageDestination) createNewLayer(index int, layerDigest digest.D
untrustedUncompressedDigest = d
}

layer, err := s.imageRef.transport.store.CreateLayer(newLayerID, parentLayer, nil, "", false, nil)
if err != nil {
return nil, err
}

flags := make(map[string]interface{})
if untrustedUncompressedDigest != "" {
flags[expectedLayerDiffIDFlag] = untrustedUncompressedDigest
Expand All @@ -783,8 +778,16 @@ func (s *storageImageDestination) createNewLayer(index int, layerDigest digest.D
options := &graphdriver.ApplyDiffWithDifferOpts{
Flags: flags,
}
if err := s.imageRef.transport.store.ApplyDiffFromStagingDirectory(layer.ID, diffOutput.Target, diffOutput, options); err != nil {
_ = s.imageRef.transport.store.Delete(layer.ID)

args := storage.ApplyStagedLayerOptions{
ID: newLayerID,
ParentLayer: parentLayer,

DiffOutput: diffOutput,
DiffOptions: options,
}
layer, err := s.imageRef.transport.store.ApplyStagedLayer(args)
if err != nil && !errors.Is(err, storage.ErrDuplicateID) {
return nil, err
}
return layer, nil
Expand Down

0 comments on commit cd36ca2

Please sign in to comment.