]> source.dussan.org Git - nextcloud-server.git/commitdiff
Fix scan permissions with nested permissions masks 5710/head
authorRobin Appelman <robin@icewind.nl>
Thu, 13 Jul 2017 12:17:52 +0000 (14:17 +0200)
committerRobin Appelman <robin@icewind.nl>
Thu, 13 Jul 2017 12:37:09 +0000 (14:37 +0200)
Signed-off-by: Robin Appelman <robin@icewind.nl>
lib/private/Files/Storage/Wrapper/PermissionsMask.php
tests/lib/Files/Storage/Wrapper/PermissionsMaskTest.php

index 1bda92f13aa0afe82711f9aad5b548ba20aa0e8a..16f0e420818729e6b539a21d7b473dfd610e505b 100644 (file)
@@ -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;
index 354db9d069da38092c93ff599d07620faeb52cf1..388272b410774e39c64233dbad2d4ade0c9b1cee 100644 (file)
@@ -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');