From cd904a9ccfd601201f1fd617ada652ca8de37619 Mon Sep 17 00:00:00 2001 From: Steve Boyd Date: Tue, 15 Aug 2023 18:06:40 +1200 Subject: [PATCH] ENH Only write file if it is different --- funcs_utils.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/funcs_utils.php b/funcs_utils.php index 3cb907f..1204683 100644 --- a/funcs_utils.php +++ b/funcs_utils.php @@ -37,6 +37,11 @@ function write_file($path, $contents) mkdir($dirname, 0775, true); } $contents = trim($contents) . "\n"; + $existingContents = file_exists($path) ? file_get_contents($path) : ''; + if ($existingContents && $existingContents === $contents) { + info("Contents of $path is already correct, continuing"); + return; + } file_put_contents($path, $contents); info("Wrote to $path"); }