From 769669d4ec2a4839cb1aa25a3a29f05aa86b83ed Mon Sep 17 00:00:00 2001 From: Ondrej Mirtes Date: Wed, 12 Feb 2020 22:15:08 +0100 Subject: [PATCH] FileCacheStorage - ignore concurrent save issues on Windows --- src/Cache/FileCacheStorage.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Cache/FileCacheStorage.php b/src/Cache/FileCacheStorage.php index f1056de591..0895758778 100644 --- a/src/Cache/FileCacheStorage.php +++ b/src/Cache/FileCacheStorage.php @@ -82,8 +82,12 @@ public function save(string $key, string $variableKey, $data): void } $renameSuccess = @rename($tmpPath, $path); - if ($renameSuccess === false) { - @unlink($tmpPath); + if ($renameSuccess) { + return; + } + + @unlink($tmpPath); + if (DIRECTORY_SEPARATOR === '/' || !file_exists($path)) { throw new \InvalidArgumentException(sprintf('Could not write data to cache file %s.', $path)); } }