From d2641b560d6012657efa653ed7275eb04964ac56 Mon Sep 17 00:00:00 2001 From: Karim PINCHON Date: Mon, 29 Jan 2018 11:05:10 +0100 Subject: [PATCH] Do not create key file if it already exists and it is the same --- src/CryptKey.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/CryptKey.php b/src/CryptKey.php index 0d5f5cf6..524bd358 100644 --- a/src/CryptKey.php +++ b/src/CryptKey.php @@ -73,7 +73,11 @@ class CryptKey $tmpDir = sys_get_temp_dir(); $keyPath = $tmpDir . '/' . sha1($key) . '.key'; - if (!file_exists($keyPath) && !touch($keyPath)) { + if (file_exists($keyPath)) { + return 'file://' . $keyPath; + } + + if (!touch($keyPath)) { // @codeCoverageIgnoreStart throw new \RuntimeException(sprintf('"%s" key file could not be created', $keyPath)); // @codeCoverageIgnoreEnd