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 a7260f4
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 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,9 +778,17 @@ 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)
return nil, err

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, fmt.Errorf("failed to put layer using a partial pull: %w", err)
}
return layer, nil
}
Expand Down

0 comments on commit a7260f4

Please sign in to comment.