Fix scan permissions with nested permissions masks

Signed-off-by: Robin Appelman <robin@icewind.nl>
This commit is contained in:
Robin Appelman 2017-07-13 14:17:52 +02:00
parent f71457782b
commit 03f27b4c2c
No known key found for this signature in database
GPG key ID: CBCA68FBAEBF98C9
2 changed files with 16 additions and 1 deletions

View file

@ -143,7 +143,7 @@ class PermissionsMask extends Wrapper {
$data = parent::getMetaData($path); $data = parent::getMetaData($path);
if ($data && isset($data['permissions'])) { 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; $data['permissions'] &= $this->mask;
} }
return $data; return $data;

View file

@ -127,6 +127,21 @@ class PermissionsMaskTest extends \Test\Files\Storage\Storage {
$this->assertEquals(Constants::PERMISSION_READ, $storage->getCache()->get('foo')->getPermissions()); $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() { public function testScanUnchanged() {
$this->sourceStorage->mkdir('foo'); $this->sourceStorage->mkdir('foo');
$this->sourceStorage->file_put_contents('foo/bar.txt', 'bar'); $this->sourceStorage->file_put_contents('foo/bar.txt', 'bar');