Skip to content

Commit 68fa0d4

Browse files
authored
Merge pull request #308 from nextcloud/fix/304/properly-check-for-downloaded-archive-2
Do not depend on the order of files in a folder
2 parents bb16762 + 21e2c82 commit 68fa0d4

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

index.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -692,14 +692,14 @@ private function getDownloadedFilePath() {
692692
$this->silentLog('[info] storage location: ' . $storageLocation);
693693

694694
$filesInStorageLocation = scandir($storageLocation);
695-
$files = array_filter($filesInStorageLocation, function($path){
695+
$files = array_values(array_filter($filesInStorageLocation, function($path){
696696
return $path !== '.' && $path !== '..';
697-
});
697+
}));
698698
// only the downloaded archive
699699
if(count($files) !== 1) {
700700
throw new \Exception('There are more files than the downloaded archive in the downloads/ folder.');
701701
}
702-
return $storageLocation . '/' . $files[2];
702+
return $storageLocation . '/' . $files[0];
703703
}
704704

705705
/**

lib/Updater.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -575,14 +575,14 @@ private function getDownloadedFilePath() {
575575
$this->silentLog('[info] storage location: ' . $storageLocation);
576576

577577
$filesInStorageLocation = scandir($storageLocation);
578-
$files = array_filter($filesInStorageLocation, function($path){
578+
$files = array_values(array_filter($filesInStorageLocation, function($path){
579579
return $path !== '.' && $path !== '..';
580-
});
580+
}));
581581
// only the downloaded archive
582582
if(count($files) !== 1) {
583583
throw new \Exception('There are more files than the downloaded archive in the downloads/ folder.');
584584
}
585-
return $storageLocation . '/' . $files[2];
585+
return $storageLocation . '/' . $files[0];
586586
}
587587

588588
/**

0 commit comments

Comments
 (0)