Merge pull request #8901 from owncloud/permissions-update-cache
Save the permissions in the filecache if it's not saved yet
This commit is contained in:
commit
75a53b3c49
|
@ -95,7 +95,7 @@ class Shared_Cache extends Cache {
|
||||||
}
|
}
|
||||||
$data['uid_owner'] = $this->storage->getOwner($file);
|
$data['uid_owner'] = $this->storage->getOwner($file);
|
||||||
if (isset($data['permissions'])) {
|
if (isset($data['permissions'])) {
|
||||||
$data['permissions'] = $data['permissions'] & $this->storage->getPermissions('');
|
$data['permissions'] &= $this->storage->getPermissions('');
|
||||||
} else {
|
} else {
|
||||||
$data['permissions'] = $this->storage->getPermissions('');
|
$data['permissions'] = $this->storage->getPermissions('');
|
||||||
}
|
}
|
||||||
|
@ -135,7 +135,7 @@ class Shared_Cache extends Cache {
|
||||||
$data['name'] = basename($this->storage->getMountPoint());
|
$data['name'] = basename($this->storage->getMountPoint());
|
||||||
$data['is_share_mount_point'] = true;
|
$data['is_share_mount_point'] = true;
|
||||||
}
|
}
|
||||||
$data['permissions'] = $data['permissions'] & $this->storage->getPermissions('');
|
$data['permissions'] &= $this->storage->getPermissions('');
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -19,13 +19,49 @@
|
||||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
use OC\Files\Cache\Cache;
|
||||||
|
use OC\Files\Storage\Storage;
|
||||||
|
use OC\Files\View;
|
||||||
|
|
||||||
require_once __DIR__ . '/base.php';
|
require_once __DIR__ . '/base.php';
|
||||||
|
|
||||||
class Test_Files_Sharing_Permissions extends Test_Files_Sharing_Base {
|
class Test_Files_Sharing_Permissions extends Test_Files_Sharing_Base {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var Storage
|
||||||
|
*/
|
||||||
private $sharedStorageRestrictedShare;
|
private $sharedStorageRestrictedShare;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var Storage
|
||||||
|
*/
|
||||||
private $sharedCacheRestrictedShare;
|
private $sharedCacheRestrictedShare;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var View
|
||||||
|
*/
|
||||||
|
private $secondView;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var Storage
|
||||||
|
*/
|
||||||
|
private $ownerStorage;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var Storage
|
||||||
|
*/
|
||||||
|
private $sharedStorage;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var Cache
|
||||||
|
*/
|
||||||
|
private $sharedCache;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var Cache
|
||||||
|
*/
|
||||||
|
private $ownerCache;
|
||||||
|
|
||||||
function setUp() {
|
function setUp() {
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
|
||||||
|
@ -105,16 +141,14 @@ class Test_Files_Sharing_Permissions extends Test_Files_Sharing_Base {
|
||||||
$this->assertEquals('subdir', $contents[0]['name']);
|
$this->assertEquals('subdir', $contents[0]['name']);
|
||||||
$this->assertEquals(31, $contents[0]['permissions']);
|
$this->assertEquals(31, $contents[0]['permissions']);
|
||||||
$this->assertEquals('textfile.txt', $contents[1]['name']);
|
$this->assertEquals('textfile.txt', $contents[1]['name']);
|
||||||
$this->assertEquals(31, $contents[1]['permissions']);
|
// 27 is correct because create is reserved to folders only - requires more unit tests overall to ensure this
|
||||||
|
$this->assertEquals(27, $contents[1]['permissions']);
|
||||||
$contents = $this->secondView->getDirectoryContent('files/shareddirrestricted');
|
$contents = $this->secondView->getDirectoryContent('files/shareddirrestricted');
|
||||||
$this->assertEquals('subdir', $contents[0]['name']);
|
$this->assertEquals('subdir', $contents[0]['name']);
|
||||||
$this->assertEquals(7, $contents[0]['permissions']);
|
$this->assertEquals(7 | \OCP\PERMISSION_DELETE, $contents[0]['permissions']);
|
||||||
$this->assertEquals('textfile1.txt', $contents[1]['name']);
|
$this->assertEquals('textfile1.txt', $contents[1]['name']);
|
||||||
$this->assertEquals(7, $contents[1]['permissions']);
|
// 3 is correct because create is reserved to folders only
|
||||||
|
// delete permissions are added since mount points can always be deleted
|
||||||
// the share mount point should always have delete permissions to allow the user
|
$this->assertEquals(3 | \OCP\PERMISSION_DELETE, $contents[1]['permissions']);
|
||||||
// to unmount it
|
|
||||||
$restrictedShare = $this->secondView->getFileInfo('files/shareddirrestricted');
|
|
||||||
$this->assertEquals(7 | \OCP\PERMISSION_DELETE, $restrictedShare['permissions']);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -861,8 +861,12 @@ class View {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($data and isset($data['fileid'])) {
|
if ($data and isset($data['fileid'])) {
|
||||||
|
if ($data['permissions'] === 0) {
|
||||||
|
$data['permissions'] = $storage->getPermissions($data['path']);
|
||||||
|
$cache->update($data['fileid'], array('permissions' => $data['permissions']));
|
||||||
|
}
|
||||||
if ($includeMountPoints and $data['mimetype'] === 'httpd/unix-directory') {
|
if ($includeMountPoints and $data['mimetype'] === 'httpd/unix-directory') {
|
||||||
//add the sizes of other mountpoints to the folder
|
//add the sizes of other mount points to the folder
|
||||||
$extOnly = ($includeMountPoints === 'ext');
|
$extOnly = ($includeMountPoints === 'ext');
|
||||||
$mountPoints = Filesystem::getMountPoints($path);
|
$mountPoints = Filesystem::getMountPoints($path);
|
||||||
foreach ($mountPoints as $mountPoint) {
|
foreach ($mountPoints as $mountPoint) {
|
||||||
|
@ -917,21 +921,17 @@ class View {
|
||||||
}
|
}
|
||||||
|
|
||||||
$folderId = $cache->getId($internalPath);
|
$folderId = $cache->getId($internalPath);
|
||||||
|
/**
|
||||||
|
* @var \OC\Files\FileInfo[] $files
|
||||||
|
*/
|
||||||
$files = array();
|
$files = array();
|
||||||
$contents = $cache->getFolderContents($internalPath, $folderId); //TODO: mimetype_filter
|
$contents = $cache->getFolderContents($internalPath, $folderId); //TODO: mimetype_filter
|
||||||
foreach ($contents as $content) {
|
foreach ($contents as $content) {
|
||||||
$files[] = new FileInfo($path . '/' . $content['name'], $storage, $content['path'], $content);
|
if ($content['permissions'] === 0) {
|
||||||
}
|
$content['permissions'] = $storage->getPermissions($content['path']);
|
||||||
|
$cache->update($content['fileid'], array('permissions' => $content['permissions']));
|
||||||
$ids = array();
|
|
||||||
foreach ($files as $i => $file) {
|
|
||||||
$files[$i]['type'] = $file['mimetype'] === 'httpd/unix-directory' ? 'dir' : 'file';
|
|
||||||
$ids[] = $file['fileid'];
|
|
||||||
|
|
||||||
if (!isset($permissions[$file['fileid']])) {
|
|
||||||
$permissions[$file['fileid']] = $storage->getPermissions($file['path']);
|
|
||||||
}
|
}
|
||||||
$files[$i]['permissions'] = $permissions[$file['fileid']];
|
$files[] = new FileInfo($path . '/' . $content['name'], $storage, $content['path'], $content);
|
||||||
}
|
}
|
||||||
|
|
||||||
//add a folder for any mountpoint in this directory and add the sizes of other mountpoints to the folders
|
//add a folder for any mountpoint in this directory and add the sizes of other mountpoints to the folders
|
||||||
|
|
Loading…
Reference in New Issue