Skip to content

Commit

Permalink
fix(PL-2763): check cache folder is empty before pulling
Browse files Browse the repository at this point in the history
  • Loading branch information
davidmdm committed Jun 18, 2024
1 parent 969ea2d commit 9fe62df
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions internal/generator/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,11 @@ func (puller ChartPuller) Pull(ctx context.Context, opts helm.PullOptions) error
mutex.Lock()
defer mutex.Unlock()

if _, err := os.Stat(opts.OutputDir); err == nil {
// If output directory exists it has been pulled by another goroutine
// No need to pull the chart
if entries, err := os.ReadDir(opts.OutputDir); err == nil && len(entries) > 0 {
// If output directory exists and has content in it,
// then it has been pulled by another goroutine: no need to pull the chart
return nil
} else if !errors.Is(err, os.ErrNotExist) {
} else if err != nil && !errors.Is(err, os.ErrNotExist) {
return fmt.Errorf("failed to stat chart cache: %w", err)
}

Expand Down

0 comments on commit 9fe62df

Please sign in to comment.