Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
run:
timeout: 3m
modules-download-mode: readonly
skip-dirs:
- test/mocks

linters-settings:
gocyclo:
Expand All @@ -17,8 +19,6 @@ issues:
- linters:
- staticcheck
text: "SA1019:"
exclude-dirs:
- test/mocks

linters:
disable-all: true
Expand Down
11 changes: 10 additions & 1 deletion pkg/backend/prune.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,18 @@ package backend

import (
"context"
"fmt"
)

// Prune prunes the unused blobs and clean up the storage.
func (b *backend) Prune(ctx context.Context, dryRun, removeUntagged bool) error {
return b.store.PerformGC(ctx, dryRun, removeUntagged)
if err := b.store.PerformGC(ctx, dryRun, removeUntagged); err != nil {
return fmt.Errorf("faile to perform gc: %w", err)
}

if err := b.store.PerformPurgeUploads(ctx, dryRun); err != nil {
return fmt.Errorf("failed to perform purge uploads: %w", err)
}

return nil
}
7 changes: 7 additions & 0 deletions pkg/storage/distribution/distribution.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"fmt"
"io"
"regexp"
"time"

distribution "github.com/distribution/distribution/v3"
registry "github.com/distribution/distribution/v3/registry/storage"
Expand Down Expand Up @@ -315,3 +316,9 @@ func (s *storage) PerformGC(ctx context.Context, dryRun, removeUntagged bool) er
RemoveUntagged: removeUntagged,
})
}

// PerformPurgeUploads performs the purge uploads in the storage to free up the space.
func (s *storage) PerformPurgeUploads(ctx context.Context, dryRun bool) error {
_, errs := registry.PurgeUploads(ctx, s.driver, time.Now(), !dryRun)
return errors.Join(errs...)
}
2 changes: 2 additions & 0 deletions pkg/storage/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ type Storage interface {
ListTags(ctx context.Context, repo string) ([]string, error)
// PerformGC performs the garbage collection in the storage to free up the space.
PerformGC(ctx context.Context, dryRun, removeUntagged bool) error
// PerformPurgeUploads performs the purge uploads in the storage to free up the space.
PerformPurgeUploads(ctx context.Context, dryRun bool) error
}

// WithRootDir sets the root directory of the storage.
Expand Down
48 changes: 48 additions & 0 deletions test/mocks/backend/backend.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

47 changes: 47 additions & 0 deletions test/mocks/storage/storage.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.