From: Michael Gapczynski Date: Fri, 8 Mar 2013 20:28:45 +0000 (-0500) Subject: Merge branch 'master' into filecache_mtime X-Git-Tag: v6.0.0alpha2~753^2~1 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=d7beac6d6f3ad588cee6c5ba8a2145b42fa184a2;p=nextcloud-server.git Merge branch 'master' into filecache_mtime Conflicts: lib/files/view.php lib/util.php tests/lib/files/cache/cache.php --- d7beac6d6f3ad588cee6c5ba8a2145b42fa184a2 diff --cc lib/files/view.php index 3348244715e,19f33ad64a2..3cea8b082dc --- a/lib/files/view.php +++ b/lib/files/view.php @@@ -245,11 -245,14 +245,15 @@@ class View if (!is_null($mtime) and !is_numeric($mtime)) { $mtime = strtotime($mtime); } - $result = $this->basicOperation('touch', $path, array('write'), $mtime); - + $hooks = array('touch'); - + if (!$this->file_exists($path)) { + $hooks[] = 'write'; + } - - return $this->basicOperation('touch', $path, $hooks, $mtime); ++ $result = $this->basicOperation('touch', $path, $hooks, $mtime); + if (!$result) { //if native touch fails, we emulate it by changing the mtime in the cache + $this->putFileInfo($path, array('mtime' => $mtime)); + } + return true; } public function file_get_contents($path) { diff --cc lib/util.php index e739f76034c,47c02074a8c..6ed3b8b942f --- a/lib/util.php +++ b/lib/util.php @@@ -73,9 -73,9 +73,9 @@@ class OC_Util * @return array */ public static function getVersion() { - // hint: We only can count up. So the internal version number - // of ownCloud 4.5 will be 4.90.0. This is not visible to the user - return array(4, 92, 11); + // hint: We only can count up. Reset minor/patchlevel when + // updating major/minor version number. - return array(4, 97, 10); ++ return array(4, 97, 11); } /** diff --cc tests/lib/files/cache/cache.php index 794664c8893,250842805e5..edcd1c487d0 --- a/tests/lib/files/cache/cache.php +++ b/tests/lib/files/cache/cache.php @@@ -204,23 -210,15 +210,32 @@@ class Cache extends \PHPUnit_Framework_ $this->assertEquals(array($storageId, 'foo'), \OC\Files\Cache\Cache::getById($id)); } + function testStorageMTime() { + $data = array('size' => 1000, 'mtime' => 20, 'mimetype' => 'foo/file'); + $this->cache->put('foo', $data); + $cachedData = $this->cache->get('foo'); + $this->assertEquals($data['mtime'], $cachedData['storage_mtime']);//if no storage_mtime is saved, mtime should be used + + $this->cache->put('foo', array('storage_mtime' => 30));//when setting storage_mtime, mtime is also set + $cachedData = $this->cache->get('foo'); + $this->assertEquals(30, $cachedData['storage_mtime']); + $this->assertEquals(30, $cachedData['mtime']); + + $this->cache->put('foo', array('mtime' => 25));//setting mtime does not change storage_mtime + $cachedData = $this->cache->get('foo'); + $this->assertEquals(30, $cachedData['storage_mtime']); + $this->assertEquals(25, $cachedData['mtime']); + } + + function testLongId() { + $storage = new LongId(array()); + $cache = $storage->getCache(); + $storageId = $storage->getId(); + $data = array('size' => 1000, 'mtime' => 20, 'mimetype' => 'foo/file'); + $id = $cache->put('foo', $data); + $this->assertEquals(array(md5($storageId), 'foo'), \OC\Files\Cache\Cache::getById($id)); + } + public function tearDown() { $this->cache->clear(); } @@@ -229,5 -227,4 +244,4 @@@ $this->storage = new \OC\Files\Storage\Temporary(array()); $this->cache = new \OC\Files\Cache\Cache($this->storage); } --} - ++}