add permissions data to the results of the cache api

This commit is contained in:
Robin Appelman 2012-10-27 10:01:20 +02:00
parent 9953427197
commit 695405dfeb
4 changed files with 30 additions and 2 deletions

View file

@ -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;
}
}

View file

@ -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;
}

View file

@ -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

View file

@ -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();
}
}