From cf124e7c759e3c5eaec526aef6b114c3a12a35f3 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 4555e13863d..943e6d39ffb 100644 --- a/lib/private/Files/ObjectStore/ObjectStoreStorage.php +++ b/lib/private/Files/ObjectStore/ObjectStoreStorage.php @@ -44,8 +44,6 @@ class ObjectStoreStorage extends Common implements IChunkedFileWrite { private string $objectPrefix = 'urn:oid:'; private LoggerInterface $logger; - - private bool $handleCopiesAsOwned; protected bool $validateWrites = true; private bool $preserveCacheItemsOnDelete = false; private ?int $totalSizeLimit = null; @@ -71,7 +69,6 @@ class ObjectStoreStorage extends Common implements IChunkedFileWrite { if (isset($parameters['validateWrites'])) { $this->validateWrites = (bool)$parameters['validateWrites']; } - $this->handleCopiesAsOwned = (bool)($parameters['handleCopiesAsOwned'] ?? false); if (isset($parameters['totalSizeLimit'])) { $this->totalSizeLimit = $parameters['totalSizeLimit']; } @@ -734,10 +731,6 @@ class ObjectStoreStorage extends Common implements IChunkedFileWrite { 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' => 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 f980b49172f..fd9eddcdb45 100644 --- a/tests/lib/Files/ObjectStore/ObjectStoreStorageTest.php +++ b/tests/lib/Files/ObjectStore/ObjectStoreStorageTest.php @@ -223,28 +223,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(); @@ -258,7 +238,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 {