Skip to content

Commit

Permalink
store: new API CleanupStagedLayer
Browse files Browse the repository at this point in the history
It uses the diff output as input and callers are not expected to know
about the Target directory.

Signed-off-by: Giuseppe Scrivano <[email protected]>
  • Loading branch information
giuseppe committed Feb 15, 2024
1 parent d6ba0c0 commit e5163a1
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions store.go
Original file line number Diff line number Diff line change
Expand Up @@ -335,13 +335,17 @@ type Store interface {
ApplyDiffFromStagingDirectory(to, stagingDirectory string, diffOutput *drivers.DriverWithDifferOutput, options *drivers.ApplyDiffWithDifferOpts) error

// CleanupStagingDirectory cleanups the staging directory. It can be used to cleanup the staging directory on errors
// Deprecated: it will be removed soon. Use CleanupStagedLayer instead.
CleanupStagingDirectory(stagingDirectory string) error

// ApplyStagedLayer combines the functions of CreateLayer and ApplyDiffFromStagingDirectory,
// marking the layer for automatic removal if applying the diff fails
// for any reason.
ApplyStagedLayer(args ApplyStagedLayerOptions) (*Layer, error)

// CleanupStagedLayer cleanups the staging directory. It can be used to cleanup the staging directory on errors
CleanupStagedLayer(diffOutput *drivers.DriverWithDifferOutput) error

// DifferTarget gets the path to the differ target.
DifferTarget(id string) (string, error)

Expand Down Expand Up @@ -3027,6 +3031,13 @@ func (s *store) CleanupStagingDirectory(stagingDirectory string) error {
return err
}

func (s *store) CleanupStagedLayer(diffOutput *drivers.DriverWithDifferOutput) error {
_, err := writeToLayerStore(s, func(rlstore rwLayerStore) (struct{}, error) {
return struct{}{}, rlstore.CleanupStagingDirectory(diffOutput.Target)
})
return err
}

func (s *store) ApplyDiffWithDiffer(to string, options *drivers.ApplyDiffWithDifferOpts, differ drivers.Differ) (*drivers.DriverWithDifferOutput, error) {
return writeToLayerStore(s, func(rlstore rwLayerStore) (*drivers.DriverWithDifferOutput, error) {
if to != "" && !rlstore.Exists(to) {
Expand Down

0 comments on commit e5163a1

Please sign in to comment.