Merge pull request #9650 from nextcloud/backport/8842/stable13

[stable13] fix(AmazonS3):  fix loop $result['Contents'] error
This commit is contained in:
Morris Jobke 2018-05-29 20:56:03 +02:00 committed by GitHub
commit b71c90bac1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 8 deletions

View File

@ -292,15 +292,17 @@ class AmazonS3 extends \OC\Files\Storage\Common {
$files[] = substr(trim($prefix['Prefix'], '/'), strlen($path));
}
}
foreach ($result['Contents'] as $object) {
if (isset($object['Key']) && $object['Key'] === $path) {
// it's the directory itself, skip
continue;
if (is_array($result['Contents'])) {
foreach ($result['Contents'] as $object) {
if (isset($object['Key']) && $object['Key'] === $path) {
// it's the directory itself, skip
continue;
}
$file = basename(
isset($object['Key']) ? $object['Key'] : $object['Prefix']
);
$files[] = $file;
}
$file = basename(
isset($object['Key']) ? $object['Key'] : $object['Prefix']
);
$files[] = $file;
}
}