summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorRobin Appelman <icewind@owncloud.com>2014-01-14 13:54:07 +0100
committerRobin Appelman <icewind@owncloud.com>2014-01-14 13:54:07 +0100
commit203d5d01cabae52373f556d50f2bb541560eb4b0 (patch)
treec2d778d8bdf6c03d739e1d2c0e3f5c22da213dbc /tests
parent3c0e4a3bc6fadc950fca73a104aa1860814061ab (diff)
downloadnextcloud-server-203d5d01cabae52373f556d50f2bb541560eb4b0.tar.gz
nextcloud-server-203d5d01cabae52373f556d50f2bb541560eb4b0.zip
Use storage_mtime when determining if we can reuse cached data while scanning
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/files/cache/updater.php2
-rw-r--r--tests/lib/files/etagtest.php23
2 files changed, 24 insertions, 1 deletions
diff --git a/tests/lib/files/cache/updater.php b/tests/lib/files/cache/updater.php
index 91e384e12af..ba103cee675 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' => 100));
$rootCachedData = $this->cache->get('');
$this->assertEquals(3 * $textSize + $imageSize, $rootCachedData['size']);
diff --git a/tests/lib/files/etagtest.php b/tests/lib/files/etagtest.php
index 6c41413c4df..14003896d66 100644
--- a/tests/lib/files/etagtest.php
+++ b/tests/lib/files/etagtest.php
@@ -11,6 +11,12 @@ namespace Test\Files;
use OC\Files\Filesystem;
use OCP\Share;
+class TemporaryNoTouch extends \OC\Files\Storage\Temporary {
+ public function touch($path, $mtime = null) {
+ return false;
+ }
+}
+
class EtagTest extends \PHPUnit_Framework_TestCase {
private $datadir;
@@ -68,6 +74,23 @@ class EtagTest extends \PHPUnit_Framework_TestCase {
$this->assertEquals($originalEtags, $this->getEtags($files));
}
+ public function testTouchNotSupported() {
+ $storage = new TemporaryNoTouch(array());
+ $scanner = $storage->getScanner();
+ 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']);
+ }
+
private function getEtags($files) {
$etags = array();
foreach ($files as $file) {