mirror of
https://github.com/nextcloud/server.git
synced 2026-05-28 04:32:30 -04:00
fix: make objectstore copy consistent with changed local storage behavior
Signed-off-by: Robin Appelman <robin@icewind.nl>
This commit is contained in:
parent
0f04a40479
commit
40c5f0e51e
2 changed files with 1 additions and 28 deletions
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Reference in a new issue