*/
private $cache;
+ /**
+ * @var \OC\Files\Cache\Permissions $permissionsCache
+ */
+ private $permissionsCache;
+
const SCAN_RECURSIVE = true;
const SCAN_SHALLOW = false;
$this->storage = $storage;
$this->storageId = $this->storage->getId();
$this->cache = $storage->getCache();
+ $this->permissionsCache = $storage->getPermissionsCache();
}
/**
$data['size'] = $this->storage->filesize($path);
}
$data['etag'] = $this->storage->getETag($path);
+ $data['storage_mtime'] = $data['mtime'];
return $data;
}
}
}
$newData = $data;
- if ($reuseExisting and $cacheData = $this->cache->get($file)) {
+ $cacheData = $this->cache->get($file);
+ if ($cacheData) {
+ $this->permissionsCache->remove($cacheData['fileid']);
+ }
+ if ($reuseExisting and $cacheData) {
// prevent empty etag
$etag = $cacheData['etag'];
$propagateETagChange = false;
$etag = $data['etag'];
$propagateETagChange = true;
}
-
// only reuse data if the file hasn't explicitly changed
if (isset($data['mtime']) && isset($cacheData['mtime']) && $data['mtime'] === $cacheData['mtime']) {
if (($reuseExisting & self::REUSE_SIZE) && ($data['size'] === -1)) {
$newChildren = array();
if ($this->storage->is_dir($path) && ($dh = $this->storage->opendir($path))) {
\OC_DB::beginTransaction();
- if(is_resource($dh)) {
+ if (is_resource($dh)) {
while (($file = readdir($dh)) !== false) {
$child = ($path) ? $path . '/' . $file : $file;
if (!Filesystem::isIgnoredDir($file)) {
* walk over any folders that are not fully scanned yet and scan them
*/
public function backgroundScan() {
- while (($path = $this->cache->getIncomplete()) !== false) {
+ $lastPath = null;
+ while (($path = $this->cache->getIncomplete()) !== false && $path !== $lastPath) {
$this->scan($path);
$this->cache->correctFolderSize($path);
+ $lastPath = $path;
}
}
}
namespace Test\Files\Cache;
+use OC\Files\Storage\Temporary;
+
class Permissions extends \PHPUnit_Framework_TestCase {
/***
* @var \OC\Files\Cache\Permissions $permissionsCache
$this->permissionsCache->removeMultiple($ids, $user);
}
+
+ public function testUpdatePermissionsOnRescan() {
+ $storage = new Temporary(array());
+ $scanner = $storage->getScanner();
+ $cache = $storage->getCache();
+ $permissionsCache = $storage->getPermissionsCache();
+
+ $storage->file_put_contents('foo.txt', 'bar');
+ $scanner->scan('');
+ $id = $cache->getId('foo.txt');
+ $permissionsCache->set($id, 'test', 1);
+
+ $scanner->scan('');
+ $this->assertEquals(-1, $permissionsCache->get($id, 'test'));
+ }
}