Skip to content

Commit f4cb78b

Browse files
authored
Merge pull request nextcloud#52242 from nextcloud/artonge/fix/copy_subfolders_s3
2 parents cc3fdf8 + e21ce79 commit f4cb78b

2 files changed

Lines changed: 16 additions & 3 deletions

File tree

lib/private/Files/ObjectStore/ObjectStoreStorage.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public function __construct(array $parameters) {
6767
$this->logger = \OCP\Server::get(LoggerInterface::class);
6868
}
6969

70-
public function mkdir(string $path, bool $force = false): bool {
70+
public function mkdir(string $path, bool $force = false, array $metadata = []): bool {
7171
$path = $this->normalizePath($path);
7272
if (!$force && $this->file_exists($path)) {
7373
$this->logger->warning("Tried to create an object store folder that already exists: $path");
@@ -77,7 +77,7 @@ public function mkdir(string $path, bool $force = false): bool {
7777
$mTime = time();
7878
$data = [
7979
'mimetype' => 'httpd/unix-directory',
80-
'size' => 0,
80+
'size' => $metadata['size'] ?? 0,
8181
'mtime' => $mTime,
8282
'storage_mtime' => $mTime,
8383
'permissions' => \OCP\Constants::PERMISSION_ALL,
@@ -709,7 +709,7 @@ private function copyInner(ICache $sourceCache, ICacheEntry $sourceEntry, string
709709
if ($cache->inCache($to)) {
710710
$cache->remove($to);
711711
}
712-
$this->mkdir($to);
712+
$this->mkdir($to, false, ['size' => $sourceEntry->getSize()]);
713713

714714
foreach ($sourceCache->getFolderContentsById($sourceEntry->getId()) as $child) {
715715
$this->copyInner($sourceCache, $child, $to . '/' . $child->getName());

tests/lib/Files/ObjectStore/ObjectStoreStorageTest.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,4 +262,17 @@ public function testCopyGrantsPermissions(): void {
262262
$this->assertTrue($cache->inCache('new.txt'));
263263
$this->assertEquals(\OCP\Constants::PERMISSION_ALL, $instance->getPermissions('new.txt'));
264264
}
265+
266+
public function testCopyFolderSize(): void {
267+
$cache = $this->instance->getCache();
268+
269+
$this->instance->mkdir('source');
270+
$this->instance->file_put_contents('source/test.txt', 'foo');
271+
$this->instance->getUpdater()->update('source/test.txt');
272+
$this->assertEquals(3, $cache->get('source')->getSize());
273+
274+
$this->assertTrue($this->instance->copy('source', 'target'));
275+
276+
$this->assertEquals(3, $cache->get('target')->getSize());
277+
}
265278
}

0 commit comments

Comments
 (0)