Merge pull request #16940 from owncloud/ext-s3-touchmtimefix

Properly set mtime on S3 for touch operation
This commit is contained in:
Thomas Müller 2015-06-22 22:25:45 +02:00
commit 25581c7b63
1 changed files with 13 additions and 8 deletions

View File

@ -443,9 +443,12 @@ class AmazonS3 extends \OC\Files\Storage\Common {
$path = $this->normalizePath($path);
$metadata = array();
if (!is_null($mtime)) {
$metadata = array('lastmodified' => $mtime);
if (is_null($mtime)) {
$mtime = time();
}
$metadata = [
'lastmodified' => gmdate(\Aws\Common\Enum\DateFormat::RFC1123, $mtime)
];
$fileType = $this->filetype($path);
try {
@ -453,22 +456,24 @@ class AmazonS3 extends \OC\Files\Storage\Common {
if ($fileType === 'dir' && ! $this->isRoot($path)) {
$path .= '/';
}
$this->getConnection()->copyObject(array(
$this->getConnection()->copyObject([
'Bucket' => $this->bucket,
'Key' => $this->cleanKey($path),
'Metadata' => $metadata,
'CopySource' => $this->bucket . '/' . $path
));
'CopySource' => $this->bucket . '/' . $path,
'MetadataDirective' => 'REPLACE',
]);
$this->testTimeout();
} else {
$mimeType = \OC_Helper::getMimetypeDetector()->detectPath($path);
$this->getConnection()->putObject(array(
$this->getConnection()->putObject([
'Bucket' => $this->bucket,
'Key' => $this->cleanKey($path),
'Metadata' => $metadata,
'Body' => '',
'ContentType' => $mimeType
));
'ContentType' => $mimeType,
'MetadataDirective' => 'REPLACE',
]);
$this->testTimeout();
}
} catch (S3Exception $e) {