diff options
Diffstat (limited to 'apps/files_external/3rdparty/aws-sdk-php/Aws/S3/Sync/AbstractSyncBuilder.php')
-rw-r--r-- | apps/files_external/3rdparty/aws-sdk-php/Aws/S3/Sync/AbstractSyncBuilder.php | 36 |
1 files changed, 25 insertions, 11 deletions
diff --git a/apps/files_external/3rdparty/aws-sdk-php/Aws/S3/Sync/AbstractSyncBuilder.php b/apps/files_external/3rdparty/aws-sdk-php/Aws/S3/Sync/AbstractSyncBuilder.php index 96d01b26c3c..a2fe0fc5b8f 100644 --- a/apps/files_external/3rdparty/aws-sdk-php/Aws/S3/Sync/AbstractSyncBuilder.php +++ b/apps/files_external/3rdparty/aws-sdk-php/Aws/S3/Sync/AbstractSyncBuilder.php @@ -18,7 +18,6 @@ namespace Aws\S3\Sync; use Aws\Common\Exception\RuntimeException; use Aws\Common\Exception\UnexpectedValueException; -use Aws\Common\Model\MultipartUpload\AbstractTransfer; use Aws\Common\Model\MultipartUpload\TransferInterface; use Aws\S3\S3Client; use Aws\S3\Iterator\OpendirIterator; @@ -169,7 +168,8 @@ abstract class AbstractSyncBuilder */ public function setKeyPrefix($keyPrefix) { - $this->keyPrefix = $keyPrefix; + // Removing leading slash + $this->keyPrefix = ltrim($keyPrefix, '/'); return $this; } @@ -275,6 +275,7 @@ abstract class AbstractSyncBuilder // Only wrap the source iterator in a changed files iterator if we are not forcing the transfers if (!$this->forcing) { + $this->sourceIterator->rewind(); $this->sourceIterator = new ChangedFilesIterator( new \NoRewindIterator($this->sourceIterator), $this->getTargetIterator(), @@ -391,11 +392,6 @@ abstract class AbstractSyncBuilder function (Event $e) use ($params) { if ($e['command'] instanceof CommandInterface) { $e['command']->overwriteWith($params); - } elseif ($e['command'] instanceof TransferInterface) { - // Multipart upload transfer object - foreach ($params as $k => $v) { - $e['command']->setOption($k, $v); - } } } ); @@ -410,12 +406,30 @@ abstract class AbstractSyncBuilder { // Ensure that the stream wrapper is registered $this->client->registerStreamWrapper(); + // Calculate the opendir() bucket and optional key prefix location - // Remove the delimiter as it is not needed for this - $dir = rtrim('s3://' . $this->bucket . ($this->keyPrefix ? ('/' . $this->keyPrefix) : ''), '/'); + $dir = "s3://{$this->bucket}"; + if ($this->keyPrefix) { + $dir .= '/' . ltrim($this->keyPrefix, '/ '); + } + // Use opendir so that we can pass stream context to the iterator - $dh = opendir($dir, stream_context_create(array('s3' => array('delimiter' => '')))); + $dh = opendir($dir, stream_context_create(array( + 's3' => array( + 'delimiter' => '', + 'listFilter' => function ($obj) { + // Ensure that we do not try to download a glacier object. + return !isset($obj['StorageClass']) || + $obj['StorageClass'] != 'GLACIER'; + } + ) + ))); + + // Add the trailing slash for the OpendirIterator concatenation + if (!$this->keyPrefix) { + $dir .= '/'; + } - return $this->filterIterator(new \NoRewindIterator(new OpendirIterator($dh, $dir . '/'))); + return $this->filterIterator(new \NoRewindIterator(new OpendirIterator($dh, $dir))); } } |