summaryrefslogtreecommitdiffstats
path: root/apps/files_external
diff options
context:
space:
mode:
authorRobin Appelman <robin@icewind.nl>2021-10-14 19:16:58 +0200
committerRobin Appelman <robin@icewind.nl>2021-10-15 15:35:09 +0200
commit294af4275c3eaf8a40564edc4706ed7fab3f18c2 (patch)
tree8948f9e33f3ad0fc32ac3a05b93202f86b77732e /apps/files_external
parent5e3c8b3af2f2b25fcadc9aaf3ed10afa6e1d63c4 (diff)
downloadnextcloud-server-294af4275c3eaf8a40564edc4706ed7fab3f18c2.tar.gz
nextcloud-server-294af4275c3eaf8a40564edc4706ed7fab3f18c2.zip
more reliable directory copy
Signed-off-by: Robin Appelman <robin@icewind.nl>
Diffstat (limited to 'apps/files_external')
-rw-r--r--apps/files_external/lib/Lib/Storage/AmazonS3.php30
1 files changed, 10 insertions, 20 deletions
diff --git a/apps/files_external/lib/Lib/Storage/AmazonS3.php b/apps/files_external/lib/Lib/Storage/AmazonS3.php
index 1ad1cd699d3..6fbe913ec7c 100644
--- a/apps/files_external/lib/Lib/Storage/AmazonS3.php
+++ b/apps/files_external/lib/Lib/Storage/AmazonS3.php
@@ -49,6 +49,7 @@ use OC\Files\Cache\CacheEntry;
use OC\Files\ObjectStore\S3ConnectionTrait;
use OC\Files\ObjectStore\S3ObjectTrait;
use OCP\Constants;
+use OCP\Files\FileInfo;
use OCP\Files\IMimeTypeDetector;
class AmazonS3 extends \OC\Files\Storage\Common {
@@ -272,7 +273,7 @@ class AmazonS3 extends \OC\Files\Storage\Common {
'Bucket' => $this->bucket,
'Key' => $path . '/',
'Body' => '',
- 'ContentType' => 'httpd/unix-directory'
+ 'ContentType' => FileInfo::MIMETYPE_FOLDER
]);
$this->testTimeout();
} catch (S3Exception $e) {
@@ -575,11 +576,11 @@ class AmazonS3 extends \OC\Files\Storage\Common {
return true;
}
- public function copy($path1, $path2) {
+ public function copy($path1, $path2, $isFile = null) {
$path1 = $this->normalizePath($path1);
$path2 = $this->normalizePath($path2);
- if ($this->is_file($path1)) {
+ if ($isFile === true || $this->is_file($path1)) {
try {
$this->getConnection()->copyObject([
'Bucket' => $this->bucket,
@@ -595,28 +596,17 @@ class AmazonS3 extends \OC\Files\Storage\Common {
$this->remove($path2);
try {
- $this->getConnection()->copyObject([
- 'Bucket' => $this->bucket,
- 'Key' => $path2 . '/',
- 'CopySource' => S3Client::encodeKey($this->bucket . '/' . $path1 . '/')
- ]);
+ $this->mkdir($path2);
$this->testTimeout();
} catch (S3Exception $e) {
\OC::$server->getLogger()->logException($e, ['app' => 'files_external']);
return false;
}
- $dh = $this->opendir($path1);
- if (is_resource($dh)) {
- while (($file = readdir($dh)) !== false) {
- if (\OC\Files\Filesystem::isIgnoredDir($file)) {
- continue;
- }
-
- $source = $path1 . '/' . $file;
- $target = $path2 . '/' . $file;
- $this->copy($source, $target);
- }
+ foreach ($this->getDirectoryContent($path1) as $item) {
+ $source = $path1 . '/' . $item['name'];
+ $target = $path2 . '/' . $item['name'];
+ $this->copy($source, $target, $item['mimetype'] !== FileInfo::MIMETYPE_FOLDER);
}
}
@@ -745,7 +735,7 @@ class AmazonS3 extends \OC\Files\Storage\Common {
} else {
return [
'name' => basename($path),
- 'mimetype' => 'httpd/unix-directory',
+ 'mimetype' => FileInfo::MIMETYPE_FOLDER,
'mtime' => time(),
'storage_mtime' => time(),
'etag' => uniqid(),