summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--apps/files_external/lib/streamwrapper.php9
-rw-r--r--lib/files/cache/scanner.php20
-rw-r--r--tests/lib/files/cache/permissions.php17
3 files changed, 40 insertions, 6 deletions
diff --git a/apps/files_external/lib/streamwrapper.php b/apps/files_external/lib/streamwrapper.php
index 4a63dfb6e02..a086f411f57 100644
--- a/apps/files_external/lib/streamwrapper.php
+++ b/apps/files_external/lib/streamwrapper.php
@@ -42,11 +42,16 @@ abstract class StreamWrapper extends Common {
}
public function isReadable($path) {
- return true; //not properly supported
+ // at least check whether it exists
+ // subclasses might want to implement this more thoroughly
+ return $this->file_exists($path);
}
public function isUpdatable($path) {
- return true; //not properly supported
+ // at least check whether it exists
+ // subclasses might want to implement this more thoroughly
+ // a non-existing file/folder isn't updatable
+ return $this->file_exists($path);
}
public function file_exists($path) {
diff --git a/lib/files/cache/scanner.php b/lib/files/cache/scanner.php
index a87d98eb7b8..af819c47c61 100644
--- a/lib/files/cache/scanner.php
+++ b/lib/files/cache/scanner.php
@@ -36,6 +36,11 @@ class Scanner extends BasicEmitter {
*/
private $cache;
+ /**
+ * @var \OC\Files\Cache\Permissions $permissionsCache
+ */
+ private $permissionsCache;
+
const SCAN_RECURSIVE = true;
const SCAN_SHALLOW = false;
@@ -46,6 +51,7 @@ class Scanner extends BasicEmitter {
$this->storage = $storage;
$this->storageId = $this->storage->getId();
$this->cache = $storage->getCache();
+ $this->permissionsCache = $storage->getPermissionsCache();
}
/**
@@ -66,6 +72,7 @@ class Scanner extends BasicEmitter {
$data['size'] = $this->storage->filesize($path);
}
$data['etag'] = $this->storage->getETag($path);
+ $data['storage_mtime'] = $data['mtime'];
return $data;
}
@@ -95,7 +102,11 @@ class Scanner extends BasicEmitter {
}
}
$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;
@@ -103,7 +114,6 @@ class Scanner extends BasicEmitter {
$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)) {
@@ -181,7 +191,7 @@ class Scanner extends BasicEmitter {
$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)) {
@@ -238,9 +248,11 @@ class Scanner extends BasicEmitter {
* 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;
}
}
}
diff --git a/tests/lib/files/cache/permissions.php b/tests/lib/files/cache/permissions.php
index 56dbbc4518e..64a32fa6b71 100644
--- a/tests/lib/files/cache/permissions.php
+++ b/tests/lib/files/cache/permissions.php
@@ -8,6 +8,8 @@
namespace Test\Files\Cache;
+use OC\Files\Storage\Temporary;
+
class Permissions extends \PHPUnit_Framework_TestCase {
/***
* @var \OC\Files\Cache\Permissions $permissionsCache
@@ -53,4 +55,19 @@ class Permissions extends \PHPUnit_Framework_TestCase {
$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'));
+ }
}