add permissions data to the results of the cache api
This commit is contained in:
parent
9953427197
commit
695405dfeb
4 changed files with 30 additions and 2 deletions
15
lib/files/cache/cache.php
vendored
15
lib/files/cache/cache.php
vendored
|
@ -286,4 +286,19 @@ class Cache {
|
|||
}
|
||||
return $files;
|
||||
}
|
||||
|
||||
/**
|
||||
* get all file ids on the files on the storage
|
||||
*
|
||||
* @return int[]
|
||||
*/
|
||||
public function getAll() {
|
||||
$query = \OC_DB::prepare('SELECT `fileid` FROM `*PREFIX*filecache` WHERE `storage` = ?');
|
||||
$result = $query->execute(array($this->storageId));
|
||||
$ids = array();
|
||||
while ($row = $result->fetchRow()) {
|
||||
$ids[] = $row['fileid'];
|
||||
}
|
||||
return $ids;
|
||||
}
|
||||
}
|
||||
|
|
3
lib/files/cache/scanner.php
vendored
3
lib/files/cache/scanner.php
vendored
|
@ -66,7 +66,8 @@ class Scanner {
|
|||
$this->scanFile($parent);
|
||||
}
|
||||
}
|
||||
$this->cache->put($file, $data);
|
||||
$id = $this->cache->put($file, $data);
|
||||
Permissions::set($id, \OC_User::getUser(), $data['permissions']);
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
|
|
@ -686,6 +686,8 @@ class View {
|
|||
}
|
||||
}
|
||||
|
||||
$data['permissions'] = Cache\Permissions::get($data['fileid'], \OC_User::getUser());
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
@ -733,8 +735,16 @@ class View {
|
|||
}
|
||||
}
|
||||
|
||||
foreach($files as $i => $file){
|
||||
$ids = array();
|
||||
|
||||
foreach ($files as $i => $file) {
|
||||
$files[$i]['type'] = $file['mimetype'] === 'httpd/unix-directory' ? 'dir' : 'file';
|
||||
$ids[] = $file['fileid'];
|
||||
}
|
||||
|
||||
$permissions = Cache\Permissions::getMultiple($ids, \OC_User::getUser());
|
||||
foreach ($files as $i => $file) {
|
||||
$files[$i]['permissions'] = $permissions[$file['fileid']];
|
||||
}
|
||||
|
||||
usort($files, "fileCmp"); //TODO: remove this once ajax is merged
|
||||
|
|
2
tests/lib/files/cache/scanner.php
vendored
2
tests/lib/files/cache/scanner.php
vendored
|
@ -106,6 +106,8 @@ class Scanner extends \UnitTestCase {
|
|||
}
|
||||
|
||||
function tearDown() {
|
||||
$ids = $this->cache->getAll();
|
||||
\OC\Files\Cache\Permissions::removeMultiple($ids, \OC_User::getUser());
|
||||
$this->cache->clear();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue