Skip to content

Commit 610407a

Browse files
icewind1991salmart-dev
authored andcommitted
fix: make objectstore copy consistent with changed local storage behavior
Signed-off-by: Robin Appelman <robin@icewind.nl> Signed-off-by: Salvatore Martire <4652631+salmart-dev@users.noreply.github.com>
1 parent dcc554c commit 610407a

2 files changed

Lines changed: 1 addition & 29 deletions

File tree

lib/private/Files/ObjectStore/ObjectStoreStorage.php

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@ class ObjectStoreStorage extends \OC\Files\Storage\Common implements IChunkedFil
3535
private string $objectPrefix = 'urn:oid:';
3636

3737
private LoggerInterface $logger;
38-
39-
private bool $handleCopiesAsOwned;
4038
protected bool $validateWrites = true;
4139
private bool $preserveCacheItemsOnDelete = false;
4240

@@ -61,7 +59,6 @@ public function __construct(array $parameters) {
6159
if (isset($parameters['validateWrites'])) {
6260
$this->validateWrites = (bool)$parameters['validateWrites'];
6361
}
64-
$this->handleCopiesAsOwned = (bool)($parameters['handleCopiesAsOwned'] ?? false);
6562

6663
$this->logger = \OCP\Server::get(LoggerInterface::class);
6764
}
@@ -729,10 +726,6 @@ private function copyFile(ICacheEntry $sourceEntry, string $to) {
729726

730727
try {
731728
$this->objectStore->copyObject($sourceUrn, $targetUrn);
732-
if ($this->handleCopiesAsOwned) {
733-
// 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 !
734-
$cache->update($targetId, ['permissions' => \OCP\Constants::PERMISSION_ALL]);
735-
}
736729
} catch (\Exception $e) {
737730
$cache->remove($to);
738731

tests/lib/Files/ObjectStore/ObjectStoreStorageTest.php

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -224,29 +224,8 @@ public function testCopyBetweenJails(): void {
224224
$this->assertEquals('2', $this->instance->file_get_contents('b/target/sub/2.txt'));
225225
$this->assertEquals('3', $this->instance->file_get_contents('b/target/sub/3.txt'));
226226
}
227-
228-
public function testCopyPreservesPermissions(): void {
229-
$cache = $this->instance->getCache();
230-
231-
$this->instance->file_put_contents('test.txt', 'foo');
232-
$this->assertTrue($cache->inCache('test.txt'));
233-
234-
$cache->update($cache->getId('test.txt'), ['permissions' => \OCP\Constants::PERMISSION_READ]);
235-
$this->assertEquals(\OCP\Constants::PERMISSION_READ, $this->instance->getPermissions('test.txt'));
236-
237-
$this->assertTrue($this->instance->copy('test.txt', 'new.txt'));
238-
239-
$this->assertTrue($cache->inCache('new.txt'));
240-
$this->assertEquals(\OCP\Constants::PERMISSION_READ, $this->instance->getPermissions('new.txt'));
241-
}
242-
243-
/**
244-
* Test that copying files will drop permissions like local storage does
245-
* TODO: Drop this and fix local storage
246-
*/
247227
public function testCopyGrantsPermissions(): void {
248228
$config['objectstore'] = $this->objectStorage;
249-
$config['handleCopiesAsOwned'] = true;
250229
$instance = new ObjectStoreStorageOverwrite($config);
251230

252231
$cache = $instance->getCache();
@@ -260,7 +239,7 @@ public function testCopyGrantsPermissions(): void {
260239
$this->assertTrue($instance->copy('test.txt', 'new.txt'));
261240

262241
$this->assertTrue($cache->inCache('new.txt'));
263-
$this->assertEquals(\OCP\Constants::PERMISSION_ALL, $instance->getPermissions('new.txt'));
242+
$this->assertEquals(\OCP\Constants::PERMISSION_ALL - \OCP\Constants::PERMISSION_CREATE, $instance->getPermissions('new.txt'));
264243
}
265244

266245
public function testCopyFolderSize(): void {

0 commit comments

Comments
 (0)