[Pkg-owncloud-commits] [owncloud] 82/104: Use storage_mtime when determining if we can reuse cached data while scanning
David Prévot
taffit at moszumanska.debian.org
Sat Jan 18 13:33:42 UTC 2014
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository owncloud.
commit 6adac6a67315e7be4cf800ed67a1b0edc5bd3ccf
Author: Robin Appelman <icewind at owncloud.com>
Date: Tue Jan 14 13:54:07 2014 +0100
Use storage_mtime when determining if we can reuse cached data while scanning
Backport to stable6 of the following commits, in order:
- 203d5d0
- 4113042
- 7e4c80f
- 16b898d
---
lib/private/files/cache/scanner.php | 2 +-
tests/lib/files/cache/scanner.php | 2 +-
tests/lib/files/cache/updater.php | 2 +-
tests/lib/files/view.php | 17 +++++++++++++++++
4 files changed, 20 insertions(+), 3 deletions(-)
diff --git a/lib/private/files/cache/scanner.php b/lib/private/files/cache/scanner.php
index a8c069e..92a4c01 100644
--- a/lib/private/files/cache/scanner.php
+++ b/lib/private/files/cache/scanner.php
@@ -122,7 +122,7 @@ class Scanner extends BasicEmitter {
$propagateETagChange = true;
}
// only reuse data if the file hasn't explicitly changed
- if (isset($data['mtime']) && isset($cacheData['mtime']) && $data['mtime'] === $cacheData['mtime']) {
+ if (isset($data['storage_mtime']) && isset($cacheData['storage_mtime']) && $data['storage_mtime'] === $cacheData['storage_mtime']) {
if (($reuseExisting & self::REUSE_SIZE) && ($data['size'] === -1)) {
$data['size'] = $cacheData['size'];
}
diff --git a/tests/lib/files/cache/scanner.php b/tests/lib/files/cache/scanner.php
index 3f3a045..3f5604b 100644
--- a/tests/lib/files/cache/scanner.php
+++ b/tests/lib/files/cache/scanner.php
@@ -147,7 +147,7 @@ class Scanner extends \PHPUnit_Framework_TestCase {
$this->scanner->scan('');
$oldData = $this->cache->get('');
$this->storage->unlink('folder/bar.txt');
- $this->cache->put('folder', array('mtime' => $this->storage->filemtime('folder')));
+ $this->cache->put('folder', array('mtime' => $this->storage->filemtime('folder'), 'storage_mtime' => $this->storage->filemtime('folder')));
$this->scanner->scan('', \OC\Files\Cache\Scanner::SCAN_SHALLOW, \OC\Files\Cache\Scanner::REUSE_SIZE);
$newData = $this->cache->get('');
$this->assertNotEquals($oldData['etag'], $newData['etag']);
diff --git a/tests/lib/files/cache/updater.php b/tests/lib/files/cache/updater.php
index 91e384e..4898614 100644
--- a/tests/lib/files/cache/updater.php
+++ b/tests/lib/files/cache/updater.php
@@ -88,7 +88,7 @@ class Updater extends \PHPUnit_Framework_TestCase {
public function testWrite() {
$textSize = strlen("dummy file data\n");
$imageSize = filesize(\OC::$SERVERROOT . '/core/img/logo.png');
- $this->cache->put('foo.txt', array('mtime' => 100));
+ $this->cache->put('foo.txt', array('mtime' => 100, 'storage_mtime' => 150));
$rootCachedData = $this->cache->get('');
$this->assertEquals(3 * $textSize + $imageSize, $rootCachedData['size']);
diff --git a/tests/lib/files/view.php b/tests/lib/files/view.php
index 76a7fd5..72a2f85 100644
--- a/tests/lib/files/view.php
+++ b/tests/lib/files/view.php
@@ -545,4 +545,21 @@ class View extends \PHPUnit_Framework_TestCase {
$this->assertContains($item['name'], $names);
}
}
+
+ public function testTouchNotSupported() {
+ $storage = new TemporaryNoTouch(array());
+ $scanner = $storage->getScanner();
+ \OC\Files\Filesystem::mount($storage, array(), '/test/');
+ $past = time() - 100;
+ $storage->file_put_contents('test', 'foobar');
+ $scanner->scan('');
+ $view = new \OC\Files\View('');
+ $info = $view->getFileInfo('/test/test');
+
+ $view->touch('/test/test', $past);
+ $scanner->scanFile('test', \OC\Files\Cache\Scanner::REUSE_ETAG);
+
+ $info2 = $view->getFileInfo('/test/test');
+ $this->assertEquals($info['etag'], $info2['etag']);
+ }
}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud.git
More information about the Pkg-owncloud-commits
mailing list