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) {
* @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);
}
/**
$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();
}
$this->storage = new \OC\Files\Storage\Temporary(array());
$this->cache = new \OC\Files\Cache\Cache($this->storage);
}
--}
-
++}