From 27dac7798edf75d80b7bdbe6213547492c8f1ea5 Mon Sep 17 00:00:00 2001 From: Morris Jobke Date: Tue, 15 Sep 2020 19:35:28 +0200 Subject: [PATCH] Do not depend on the order of files in a folder Signed-off-by: Morris Jobke --- index.php | 6 +++--- lib/Updater.php | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/index.php b/index.php index 5ce9d5b9..74bd1236 100644 --- a/index.php +++ b/index.php @@ -692,14 +692,14 @@ private function getDownloadedFilePath() { $this->silentLog('[info] storage location: ' . $storageLocation); $filesInStorageLocation = scandir($storageLocation); - $files = array_filter($filesInStorageLocation, function($path){ + $files = array_values(array_filter($filesInStorageLocation, function($path){ return $path !== '.' && $path !== '..'; - }); + })); // only the downloaded archive if(count($files) !== 1) { throw new \Exception('There are more files than the downloaded archive in the downloads/ folder.'); } - return $storageLocation . '/' . $files[2]; + return $storageLocation . '/' . $files[0]; } /** diff --git a/lib/Updater.php b/lib/Updater.php index 7625688b..8faadc66 100644 --- a/lib/Updater.php +++ b/lib/Updater.php @@ -575,14 +575,14 @@ private function getDownloadedFilePath() { $this->silentLog('[info] storage location: ' . $storageLocation); $filesInStorageLocation = scandir($storageLocation); - $files = array_filter($filesInStorageLocation, function($path){ + $files = array_values(array_filter($filesInStorageLocation, function($path){ return $path !== '.' && $path !== '..'; - }); + })); // only the downloaded archive if(count($files) !== 1) { throw new \Exception('There are more files than the downloaded archive in the downloads/ folder.'); } - return $storageLocation . '/' . $files[2]; + return $storageLocation . '/' . $files[0]; } /**