add View->putFileInfo to the filecache api
This commit is contained in:
parent
e63e246c48
commit
7ef0ffe8ad
2 changed files with 35 additions and 2 deletions
|
@ -663,7 +663,7 @@ class View {
|
||||||
$path = \OC\Files\Filesystem::normalizePath($this->fakeRoot . '/' . $path);
|
$path = \OC\Files\Filesystem::normalizePath($this->fakeRoot . '/' . $path);
|
||||||
/**
|
/**
|
||||||
* @var \OC\Files\Storage\Storage $storage
|
* @var \OC\Files\Storage\Storage $storage
|
||||||
* @var string $path
|
* @var string $internalPath
|
||||||
*/
|
*/
|
||||||
list($storage, $internalPath) = \OC\Files\Filesystem::resolvePath($path);
|
list($storage, $internalPath) = \OC\Files\Filesystem::resolvePath($path);
|
||||||
$cache = $storage->getCache();
|
$cache = $storage->getCache();
|
||||||
|
@ -700,7 +700,7 @@ class View {
|
||||||
$path = \OC\Files\Filesystem::normalizePath($this->fakeRoot . '/' . $directory);
|
$path = \OC\Files\Filesystem::normalizePath($this->fakeRoot . '/' . $directory);
|
||||||
/**
|
/**
|
||||||
* @var \OC\Files\Storage\Storage $storage
|
* @var \OC\Files\Storage\Storage $storage
|
||||||
* @var string $path
|
* @var string $internalPath
|
||||||
*/
|
*/
|
||||||
list($storage, $internalPath) = \OC\Files\Filesystem::resolvePath($path);
|
list($storage, $internalPath) = \OC\Files\Filesystem::resolvePath($path);
|
||||||
$cache = $storage->getCache();
|
$cache = $storage->getCache();
|
||||||
|
@ -737,4 +737,30 @@ class View {
|
||||||
usort($files, "fileCmp"); //TODO: remove this once ajax is merged
|
usort($files, "fileCmp"); //TODO: remove this once ajax is merged
|
||||||
return $files;
|
return $files;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* change file metadata
|
||||||
|
*
|
||||||
|
* @param string $path
|
||||||
|
* @param array $data
|
||||||
|
* @return int
|
||||||
|
*
|
||||||
|
* returns the fileid of the updated file
|
||||||
|
*/
|
||||||
|
public function putFileInfo($path, $data) {
|
||||||
|
$path = \OC\Files\Filesystem::normalizePath($this->fakeRoot . '/' . $path);
|
||||||
|
/**
|
||||||
|
* @var \OC\Files\Storage\Storage $storage
|
||||||
|
* @var string $internalPath
|
||||||
|
*/
|
||||||
|
list($storage, $internalPath) = \OC\Files\Filesystem::resolvePath($path);
|
||||||
|
$cache = $storage->getCache();
|
||||||
|
|
||||||
|
if (!$cache->inCache($internalPath)) {
|
||||||
|
$scanner = $storage->getScanner();
|
||||||
|
$scanner->scan($internalPath, \OC\Files\Cache\Scanner::SCAN_SHALLOW);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $cache->put($internalPath, $data);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,6 +72,13 @@ class View extends \PHPUnit_Framework_TestCase {
|
||||||
|
|
||||||
$folderView = new \OC\Files\View('/folder');
|
$folderView = new \OC\Files\View('/folder');
|
||||||
$this->assertEquals($rootView->getFileInfo('/folder'), $folderView->getFileInfo('/'));
|
$this->assertEquals($rootView->getFileInfo('/folder'), $folderView->getFileInfo('/'));
|
||||||
|
|
||||||
|
$cachedData = $rootView->getFileInfo('/foo.txt');
|
||||||
|
$this->assertFalse($cachedData['encrypted']);
|
||||||
|
$id = $rootView->putFileInfo('/foo.txt', array('encrypted' => true));
|
||||||
|
$cachedData = $rootView->getFileInfo('/foo.txt');
|
||||||
|
$this->assertTrue($cachedData['encrypted']);
|
||||||
|
$this->assertEquals($cachedData['fileid'], $id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testAutoScan() {
|
public function testAutoScan() {
|
||||||
|
|
Loading…
Reference in a new issue