Skip to content

Commit

Permalink
Do not depend on the order of files in a folder
Browse files Browse the repository at this point in the history
Signed-off-by: Morris Jobke <hey@morrisjobke.de>
  • Loading branch information
MorrisJobke committed Sep 15, 2020
1 parent d0ca75d commit bfdc40b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}

/**
Expand Down
6 changes: 3 additions & 3 deletions lib/Updater.php
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}

/**
Expand Down

0 comments on commit bfdc40b

Please sign in to comment.