diff options
author | Morris Jobke <hey@morrisjobke.de> | 2020-09-15 20:35:28 +0300 |
---|---|---|
committer | Morris Jobke <hey@morrisjobke.de> | 2020-09-15 20:35:28 +0300 |
commit | 21e2c82b76f4818ed01658c6a0fea03736f77462 (patch) | |
tree | a875456fcf3dd48ea81d704e7459830d4cf81c0d | |
parent | bb1676232cbdfdbaee7f11b5969f82fbbab145cb (diff) |
Do not depend on the order of files in a folder
Signed-off-by: Morris Jobke <hey@morrisjobke.de>
-rw-r--r-- | index.php | 6 | ||||
-rw-r--r-- | lib/Updater.php | 6 |
2 files changed, 6 insertions, 6 deletions
@@ -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]; } /** |