From 21e2c82b76f4818ed01658c6a0fea03736f77462 Mon Sep 17 00:00:00 2001 From: Morris Jobke Date: Tue, 15 Sep 2020 19:35:28 +0200 Subject: 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 9e5526b..4ff85f4 100644 --- a/index.php +++ b/index.php @@ -692,14 +692,14 @@ class Updater { $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 d0c8397..e62b79f 100644 --- a/lib/Updater.php +++ b/lib/Updater.php @@ -575,14 +575,14 @@ class Updater { $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]; } /** -- cgit v1.2.3