Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 3dfbfca

Browse filesBrowse files
committed
feat: improve stale temp directories background cleanup
1 parent 6004fc6 commit 3dfbfca
Copy full SHA for 3dfbfca

File tree

1 file changed

+14
-2
lines changed
Filter options

1 file changed

+14
-2
lines changed

‎local/php/executor.go

Copy file name to clipboardExpand all lines: local/php/executor.go
+14-2Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -292,13 +292,22 @@ func (e *Executor) Config(loadDotEnv bool) error {
292292
}
293293

294294
func (e *Executor) CleanupTemporaryDirectories() {
295-
go cleanupStaleTemporaryDirectories(e.Logger)
295+
backgroundCleanup := make(chan bool, 1)
296+
go cleanupStaleTemporaryDirectories(e.Logger, backgroundCleanup)
297+
296298
if e.iniDir != "" {
297299
os.RemoveAll(e.iniDir)
298300
}
299301
if e.tempDir != "" {
300302
os.RemoveAll(e.tempDir)
301303
}
304+
305+
// give some room to the background clean up job to do its work
306+
select {
307+
case <-backgroundCleanup:
308+
case <-time.After(100 * time.Millisecond):
309+
e.Logger.Debug().Msg("Allocated time for temporary directories to be cleaned up is over, it will resume later on")
310+
}
302311
}
303312

304313
// The Symfony CLI used to leak temporary directories until v5.10.8. The bug is
@@ -307,7 +316,10 @@ func (e *Executor) CleanupTemporaryDirectories() {
307316
// in-use by running servers we can't simply delete the parent directory. This
308317
// is why we make our best to find the oldest directories and remove then,
309318
// cleaning the directory little by little.
310-
func cleanupStaleTemporaryDirectories(mainLogger zerolog.Logger) {
319+
func cleanupStaleTemporaryDirectories(mainLogger zerolog.Logger, doneCh chan<- bool) {
320+
defer func() {
321+
doneCh <- true
322+
}()
311323
parentDirectory := filepath.Join(util.GetHomeDir(), "tmp")
312324
mainLogger = mainLogger.With().Str("dir", parentDirectory).Logger()
313325

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.