summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobin Appelman <robin@icewind.nl>2017-07-13 14:17:52 +0200
committerRobin Appelman <robin@icewind.nl>2017-07-13 14:29:04 +0200
commit03f27b4c2c2c3a6d3187a877cf5feb93830b7a9f (patch)
treefe78c15253a6ccd3ec84416b6e50f93583fc241a
parentf71457782b1c0e6aa66ba6b2aac126aa5a2bc9dc (diff)
downloadnextcloud-server-03f27b4c2c2c3a6d3187a877cf5feb93830b7a9f.tar.gz
nextcloud-server-03f27b4c2c2c3a6d3187a877cf5feb93830b7a9f.zip
Fix scan permissions with nested permissions masks
Signed-off-by: Robin Appelman <robin@icewind.nl>
-rw-r--r--lib/private/Files/Storage/Wrapper/PermissionsMask.php2
-rw-r--r--tests/lib/Files/Storage/Wrapper/PermissionsMaskTest.php15
2 files changed, 16 insertions, 1 deletions
diff --git a/lib/private/Files/Storage/Wrapper/PermissionsMask.php b/lib/private/Files/Storage/Wrapper/PermissionsMask.php
index 1bda92f13aa..16f0e420818 100644
--- a/lib/private/Files/Storage/Wrapper/PermissionsMask.php
+++ b/lib/private/Files/Storage/Wrapper/PermissionsMask.php
@@ -143,7 +143,7 @@ class PermissionsMask extends Wrapper {
$data = parent::getMetaData($path);
if ($data && isset($data['permissions'])) {
- $data['scan_permissions'] = $data['permissions'];
+ $data['scan_permissions'] = isset($data['scan_permissions']) ? $data['scan_permissions'] : $data['permissions'];
$data['permissions'] &= $this->mask;
}
return $data;
diff --git a/tests/lib/Files/Storage/Wrapper/PermissionsMaskTest.php b/tests/lib/Files/Storage/Wrapper/PermissionsMaskTest.php
index 354db9d069d..388272b4107 100644
--- a/tests/lib/Files/Storage/Wrapper/PermissionsMaskTest.php
+++ b/tests/lib/Files/Storage/Wrapper/PermissionsMaskTest.php
@@ -127,6 +127,21 @@ class PermissionsMaskTest extends \Test\Files\Storage\Storage {
$this->assertEquals(Constants::PERMISSION_READ, $storage->getCache()->get('foo')->getPermissions());
}
+ public function testScanNewFilesNested() {
+ $storage = $this->getMaskedStorage(Constants::PERMISSION_READ + Constants::PERMISSION_CREATE + Constants::PERMISSION_UPDATE);
+ $nestedStorage = new \OC\Files\Storage\Wrapper\PermissionsMask(array(
+ 'storage' => $storage,
+ 'mask' => Constants::PERMISSION_READ + Constants::PERMISSION_CREATE
+ ));
+ $wrappedStorage = new Wrapper(['storage' => $nestedStorage]);
+ $wrappedStorage->file_put_contents('foo', 'bar');
+ $wrappedStorage->getScanner()->scan('');
+
+ $this->assertEquals(Constants::PERMISSION_ALL - Constants::PERMISSION_CREATE, $this->sourceStorage->getCache()->get('foo')->getPermissions());
+ $this->assertEquals(Constants::PERMISSION_READ + Constants::PERMISSION_UPDATE, $storage->getCache()->get('foo')->getPermissions());
+ $this->assertEquals(Constants::PERMISSION_READ, $wrappedStorage->getCache()->get('foo')->getPermissions());
+ }
+
public function testScanUnchanged() {
$this->sourceStorage->mkdir('foo');
$this->sourceStorage->file_put_contents('foo/bar.txt', 'bar');