From ce2d4ea1ebd90881da8659583f31719d11d92ba2 Mon Sep 17 00:00:00 2001 From: Sebastian Meyer Date: Tue, 12 Dec 2017 16:21:13 +0100 Subject: [PATCH] Distinguish newly added files from updates --- update.php | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/update.php b/update.php index 2c9e4ea..e3dde2a 100644 --- a/update.php +++ b/update.php @@ -127,7 +127,22 @@ foreach ($todo as $identifier => $task) { if ($task === 'update') { - if (md5_file($sourceDir.$identifier.'.xml') !== md5_file($dataDir.$identifier.'.xml')) { + if (!file_exists($dataDir.$identifier.'.xml')) { + + // Add file + if (copy($sourceDir.$identifier.'.xml', $dataDir.$identifier.'.xml')) { + + echo format('added', 'green')."\n"; + + } else { + + echo format('addition failed', 'red')."\n"; + + $error = true; + + } + + } elseif (md5_file($sourceDir.$identifier.'.xml') !== md5_file($dataDir.$identifier.'.xml')) { // Replace file if (copy($sourceDir.$identifier.'.xml', $dataDir.$identifier.'.xml')) {