aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVincent Petry <pvince81@owncloud.com>2015-06-15 17:35:09 +0200
committerVincent Petry <pvince81@owncloud.com>2015-06-15 17:35:09 +0200
commitf98030020f5b368d24a8c25c24ef59dd4539137b (patch)
tree411081ea1023dff6dd9741e970c944301719cfb1
parentb6165b68655fdf957d9b63ab982a5f8724fcc3de (diff)
downloadnextcloud-server-f98030020f5b368d24a8c25c24ef59dd4539137b.tar.gz
nextcloud-server-f98030020f5b368d24a8c25c24ef59dd4539137b.zip
Properly set mtime on S3 for touch operation
The code was missing the "MetadataDirective". Once added, some other parts of the code failed because the format of mtime was wrong. So this PR uses the RFC format that the S3 library already uses. Additionally, the code path where mtime is null was missing. Now defaulting to the current time.
-rw-r--r--apps/files_external/lib/amazons3.php21
1 files changed, 13 insertions, 8 deletions
diff --git a/apps/files_external/lib/amazons3.php b/apps/files_external/lib/amazons3.php
index acf976e8fe4..01b4671ee92 100644
--- a/apps/files_external/lib/amazons3.php
+++ b/apps/files_external/lib/amazons3.php
@@ -439,9 +439,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 {
@@ -449,22 +452,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) {