Skip to content

Commit 5ae7778

Browse files
authored
Only checkout repo archive if steps will be executed (#534)
Since we use a "reference counting" mechanism when checking out archives we shouldn't bump the ref count if we never execute steps. Because only after executing the steps do we decrease the ref count and thus "free" the archive to be cleaned up. The problem is that if a `Task` has a cache hit then the ref will never be decreased and the archive never cleaned up.
1 parent 6bccea9 commit 5ae7778

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

internal/batches/executor/executor.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,6 @@ func New(opts Opts, client api.Client, features batches.FeatureFlags) *executor
228228
}
229229

230230
func (x *executor) AddTask(task *Task) {
231-
task.Archive = x.fetcher.Checkout(task.Repository, task.ArchivePathToFetch())
232231
x.tasks = append(x.tasks, task)
233232

234233
x.statusesMu.Lock()
@@ -377,6 +376,9 @@ func (x *executor) do(ctx context.Context, task *Task) (err error) {
377376
log.Close()
378377
}()
379378

379+
// Now checkout the archive
380+
task.Archive = x.fetcher.Checkout(task.Repository, task.ArchivePathToFetch())
381+
380382
// Set up our timeout.
381383
runCtx, cancel := context.WithTimeout(ctx, x.timeout)
382384
defer cancel()

0 commit comments

Comments
 (0)