Skip to content

Commit cf124e7

Browse files
committed
fix: make objectstore copy consistent with changed local storage behavior
Signed-off-by: Robin Appelman <robin@icewind.nl>
1 parent 7dccf5f commit cf124e7

2 files changed

Lines changed: 1 addition & 28 deletions

File tree

lib/private/Files/ObjectStore/ObjectStoreStorage.php

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,6 @@ class ObjectStoreStorage extends Common implements IChunkedFileWrite {
4444
private string $objectPrefix = 'urn:oid:';
4545

4646
private LoggerInterface $logger;
47-
48-
private bool $handleCopiesAsOwned;
4947
protected bool $validateWrites = true;
5048
private bool $preserveCacheItemsOnDelete = false;
5149
private ?int $totalSizeLimit = null;
@@ -71,7 +69,6 @@ public function __construct(array $parameters) {
7169
if (isset($parameters['validateWrites'])) {
7270
$this->validateWrites = (bool)$parameters['validateWrites'];
7371
}
74-
$this->handleCopiesAsOwned = (bool)($parameters['handleCopiesAsOwned'] ?? false);
7572
if (isset($parameters['totalSizeLimit'])) {
7673
$this->totalSizeLimit = $parameters['totalSizeLimit'];
7774
}
@@ -734,10 +731,6 @@ private function copyFile(ICacheEntry $sourceEntry, string $to) {
734731

735732
try {
736733
$this->objectStore->copyObject($sourceUrn, $targetUrn);
737-
if ($this->handleCopiesAsOwned) {
738-
// 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 !
739-
$cache->update($targetId, ['permissions' => Constants::PERMISSION_ALL]);
740-
}
741734
} catch (\Exception $e) {
742735
$cache->remove($to);
743736

tests/lib/Files/ObjectStore/ObjectStoreStorageTest.php

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -223,28 +223,8 @@ public function testCopyBetweenJails(): void {
223223
$this->assertEquals('3', $this->instance->file_get_contents('b/target/sub/3.txt'));
224224
}
225225

226-
public function testCopyPreservesPermissions(): void {
227-
$cache = $this->instance->getCache();
228-
229-
$this->instance->file_put_contents('test.txt', 'foo');
230-
$this->assertTrue($cache->inCache('test.txt'));
231-
232-
$cache->update($cache->getId('test.txt'), ['permissions' => Constants::PERMISSION_READ]);
233-
$this->assertEquals(Constants::PERMISSION_READ, $this->instance->getPermissions('test.txt'));
234-
235-
$this->assertTrue($this->instance->copy('test.txt', 'new.txt'));
236-
237-
$this->assertTrue($cache->inCache('new.txt'));
238-
$this->assertEquals(Constants::PERMISSION_READ, $this->instance->getPermissions('new.txt'));
239-
}
240-
241-
/**
242-
* Test that copying files will drop permissions like local storage does
243-
* TODO: Drop this and fix local storage
244-
*/
245226
public function testCopyGrantsPermissions(): void {
246227
$config['objectstore'] = $this->objectStorage;
247-
$config['handleCopiesAsOwned'] = true;
248228
$instance = new ObjectStoreStorageOverwrite($config);
249229

250230
$cache = $instance->getCache();
@@ -258,7 +238,7 @@ public function testCopyGrantsPermissions(): void {
258238
$this->assertTrue($instance->copy('test.txt', 'new.txt'));
259239

260240
$this->assertTrue($cache->inCache('new.txt'));
261-
$this->assertEquals(Constants::PERMISSION_ALL, $instance->getPermissions('new.txt'));
241+
$this->assertEquals(Constants::PERMISSION_ALL - Constants::PERMISSION_CREATE, $instance->getPermissions('new.txt'));
262242
}
263243

264244
public function testCopyFolderSize(): void {

0 commit comments

Comments
 (0)