mirror of
https://github.com/nextcloud/server.git
synced 2026-02-18 18:28:50 -05:00
Merge pull request #52242 from nextcloud/artonge/fix/copy_subfolders_s3
This commit is contained in:
commit
f4cb78b905
2 changed files with 16 additions and 3 deletions
|
|
@ -67,7 +67,7 @@ class ObjectStoreStorage extends \OC\Files\Storage\Common implements IChunkedFil
|
|||
$this->logger = \OCP\Server::get(LoggerInterface::class);
|
||||
}
|
||||
|
||||
public function mkdir(string $path, bool $force = false): bool {
|
||||
public function mkdir(string $path, bool $force = false, array $metadata = []): bool {
|
||||
$path = $this->normalizePath($path);
|
||||
if (!$force && $this->file_exists($path)) {
|
||||
$this->logger->warning("Tried to create an object store folder that already exists: $path");
|
||||
|
|
@ -77,7 +77,7 @@ class ObjectStoreStorage extends \OC\Files\Storage\Common implements IChunkedFil
|
|||
$mTime = time();
|
||||
$data = [
|
||||
'mimetype' => 'httpd/unix-directory',
|
||||
'size' => 0,
|
||||
'size' => $metadata['size'] ?? 0,
|
||||
'mtime' => $mTime,
|
||||
'storage_mtime' => $mTime,
|
||||
'permissions' => \OCP\Constants::PERMISSION_ALL,
|
||||
|
|
@ -709,7 +709,7 @@ class ObjectStoreStorage extends \OC\Files\Storage\Common implements IChunkedFil
|
|||
if ($cache->inCache($to)) {
|
||||
$cache->remove($to);
|
||||
}
|
||||
$this->mkdir($to);
|
||||
$this->mkdir($to, false, ['size' => $sourceEntry->getSize()]);
|
||||
|
||||
foreach ($sourceCache->getFolderContentsById($sourceEntry->getId()) as $child) {
|
||||
$this->copyInner($sourceCache, $child, $to . '/' . $child->getName());
|
||||
|
|
|
|||
|
|
@ -262,4 +262,17 @@ class ObjectStoreStorageTest extends Storage {
|
|||
$this->assertTrue($cache->inCache('new.txt'));
|
||||
$this->assertEquals(\OCP\Constants::PERMISSION_ALL, $instance->getPermissions('new.txt'));
|
||||
}
|
||||
|
||||
public function testCopyFolderSize(): void {
|
||||
$cache = $this->instance->getCache();
|
||||
|
||||
$this->instance->mkdir('source');
|
||||
$this->instance->file_put_contents('source/test.txt', 'foo');
|
||||
$this->instance->getUpdater()->update('source/test.txt');
|
||||
$this->assertEquals(3, $cache->get('source')->getSize());
|
||||
|
||||
$this->assertTrue($this->instance->copy('source', 'target'));
|
||||
|
||||
$this->assertEquals(3, $cache->get('target')->getSize());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue