From 078b25162d7f5d84a8b40a7d92e453eed8b435b7 Mon Sep 17 00:00:00 2001 From: Joren Van Hocht Date: Mon, 7 Sep 2020 20:25:42 +0200 Subject: [PATCH 1/2] =?UTF-8?q?Force=20php=20garbage=20collection=20cycle?= =?UTF-8?q?=20with=20=E2=80=9Cgr=5Fcollect=5Fcycles=E2=80=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/TemporaryDirectory.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/TemporaryDirectory.php b/src/TemporaryDirectory.php index fdb93f6..13a9295 100644 --- a/src/TemporaryDirectory.php +++ b/src/TemporaryDirectory.php @@ -161,6 +161,8 @@ protected function deleteDirectory(string $path): bool } } + gc_collect_cycles(); + return rmdir($path); } } From fb32d59d40f695cd536d2926548fee651b0d8ab0 Mon Sep 17 00:00:00 2001 From: Freek Van der Herten Date: Mon, 7 Sep 2020 22:40:28 +0200 Subject: [PATCH 2/2] Update TemporaryDirectory.php --- src/TemporaryDirectory.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/TemporaryDirectory.php b/src/TemporaryDirectory.php index 13a9295..039928a 100644 --- a/src/TemporaryDirectory.php +++ b/src/TemporaryDirectory.php @@ -161,6 +161,10 @@ protected function deleteDirectory(string $path): bool } } + /* + * By forcing a php garbage collection cycle using gc_collect_cycles() we can ensure + * that the rmdir does not fail due to files still being reserved in memory. + */ gc_collect_cycles(); return rmdir($path);