From 40c5f0e51e59953c9db44022a762e2446f5b686a Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Tue, 10 Mar 2026 16:07:38 +0100 Subject: [PATCH] fix: make objectstore copy consistent with changed local storage behavior Signed-off-by: Robin Appelman --- .../Files/ObjectStore/ObjectStoreStorage.php | 7 ------ .../ObjectStore/ObjectStoreStorageTest.php | 22 +------------------ 2 files changed, 1 insertion(+), 28 deletions(-) diff --git a/lib/private/Files/ObjectStore/ObjectStoreStorage.php b/lib/private/Files/ObjectStore/ObjectStoreStorage.php index 6e411084ef2..8c9634e8ef2 100644 --- a/lib/private/Files/ObjectStore/ObjectStoreStorage.php +++ b/lib/private/Files/ObjectStore/ObjectStoreStorage.php @@ -36,8 +36,6 @@ class ObjectStoreStorage extends \OC\Files\Storage\Common implements IChunkedFil private string $objectPrefix = 'urn:oid:'; private LoggerInterface $logger; - - private bool $handleCopiesAsOwned; protected bool $validateWrites = true; private bool $preserveCacheItemsOnDelete = false; @@ -62,7 +60,6 @@ class ObjectStoreStorage extends \OC\Files\Storage\Common implements IChunkedFil if (isset($parameters['validateWrites'])) { $this->validateWrites = (bool)$parameters['validateWrites']; } - $this->handleCopiesAsOwned = (bool)($parameters['handleCopiesAsOwned'] ?? false); $this->logger = \OCP\Server::get(LoggerInterface::class); } @@ -722,10 +719,6 @@ class ObjectStoreStorage extends \OC\Files\Storage\Common implements IChunkedFil try { $this->objectStore->copyObject($sourceUrn, $targetUrn); - if ($this->handleCopiesAsOwned) { - // Copied the file thus we gain all permissions as we are the owner now ! warning while this aligns with local storage it should not be used and instead fix local storage ! - $cache->update($targetId, ['permissions' => \OCP\Constants::PERMISSION_ALL]); - } } catch (\Exception $e) { $cache->remove($to); diff --git a/tests/lib/Files/ObjectStore/ObjectStoreStorageTest.php b/tests/lib/Files/ObjectStore/ObjectStoreStorageTest.php index 3387808445a..f58c5eecf5a 100644 --- a/tests/lib/Files/ObjectStore/ObjectStoreStorageTest.php +++ b/tests/lib/Files/ObjectStore/ObjectStoreStorageTest.php @@ -225,28 +225,8 @@ class ObjectStoreStorageTest extends Storage { $this->assertEquals('3', $this->instance->file_get_contents('b/target/sub/3.txt')); } - public function testCopyPreservesPermissions(): void { - $cache = $this->instance->getCache(); - - $this->instance->file_put_contents('test.txt', 'foo'); - $this->assertTrue($cache->inCache('test.txt')); - - $cache->update($cache->getId('test.txt'), ['permissions' => Constants::PERMISSION_READ]); - $this->assertEquals(Constants::PERMISSION_READ, $this->instance->getPermissions('test.txt')); - - $this->assertTrue($this->instance->copy('test.txt', 'new.txt')); - - $this->assertTrue($cache->inCache('new.txt')); - $this->assertEquals(Constants::PERMISSION_READ, $this->instance->getPermissions('new.txt')); - } - - /** - * Test that copying files will drop permissions like local storage does - * TODO: Drop this and fix local storage - */ public function testCopyGrantsPermissions(): void { $config['objectstore'] = $this->objectStorage; - $config['handleCopiesAsOwned'] = true; $instance = new ObjectStoreStorageOverwrite($config); $cache = $instance->getCache(); @@ -260,7 +240,7 @@ class ObjectStoreStorageTest extends Storage { $this->assertTrue($instance->copy('test.txt', 'new.txt')); $this->assertTrue($cache->inCache('new.txt')); - $this->assertEquals(Constants::PERMISSION_ALL, $instance->getPermissions('new.txt')); + $this->assertEquals(Constants::PERMISSION_ALL - Constants::PERMISSION_CREATE, $instance->getPermissions('new.txt')); } public function testCopyFolderSize(): void {