From ed63c1ffe5c6e7ede67f41ff12495dff45b001a0 Mon Sep 17 00:00:00 2001
From: Dave Mc Nicoll <info@mcnd.ca>
Date: Thu, 1 Feb 2024 14:53:47 +0000
Subject: [PATCH] - Making sure cache file exist before invalidating; creating
 it if it ain't

---
 src/CacheInvalidator.php | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/CacheInvalidator.php b/src/CacheInvalidator.php
index d8a64f9..8ed6a0d 100644
--- a/src/CacheInvalidator.php
+++ b/src/CacheInvalidator.php
@@ -12,13 +12,13 @@ class CacheInvalidator
         protected string $filePath,
         protected bool $updateVersion = false,
     ) {
-        if ($this->updateVersion) {
+        if ($this->updateVersion || ! file_exists($this->filePath)) {
             $this->version = $this->generateVersion();
             file_put_contents($this->filePath, $this->version);
         }
         else {
-            $this->version = file_get_contents($this->filePath);
-        }
+           $this->version = file_get_contents($this->filePath);
+         }
     }
 
     protected function generateVersion() : string
@@ -30,4 +30,4 @@ class CacheInvalidator
     {
         return $this->version;
     }
-}
\ No newline at end of file
+}