diff --git a/apps/files_external/lib/Lib/Storage/AmazonS3.php b/apps/files_external/lib/Lib/Storage/AmazonS3.php index 03a24e89765f3a344efd8593f99aa84fde08b46d..f06247c3690055b40ef2990b99797b3aaa2fb677 100644 --- a/apps/files_external/lib/Lib/Storage/AmazonS3.php +++ b/apps/files_external/lib/Lib/Storage/AmazonS3.php @@ -101,7 +101,7 @@ class AmazonS3 extends \OC\Files\Storage\Common { $keys = array_keys($this->objectCache->getData()); $keyLength = strlen($key); foreach ($keys as $existingKey) { - if (substr($existingKey, 0, $keyLength) === $keys) { + if (substr($existingKey, 0, $keyLength) === $key) { unset($this->objectCache[$existingKey]); } } @@ -242,17 +242,22 @@ class AmazonS3 extends \OC\Files\Storage\Common { $params['Prefix'] = $path . '/'; } try { + $connection = $this->getConnection(); // Since there are no real directories on S3, we need // to delete all objects prefixed with the path. do { // instead of the iterator, manually loop over the list ... - $objects = $this->getConnection()->listObjects($params); + $objects = $connection->listObjects($params); // ... so we can delete the files in batches - $this->getConnection()->deleteObjects(array( - 'Bucket' => $this->bucket, - 'Objects' => $objects['Contents'] - )); - $this->testTimeout(); + if (isset($objects['Contents'])) { + $connection->deleteObjects([ + 'Bucket' => $this->bucket, + 'Delete' => [ + 'Objects' => $objects['Contents'] + ] + ]); + $this->testTimeout(); + } // we reached the end when the list is no longer truncated } while ($objects['IsTruncated']); } catch (S3Exception $e) {