check for changes when using the cache api

This commit is contained in:
Robin Appelman 2012-10-28 11:43:45 +01:00
parent fba7be1194
commit b07672821b
2 changed files with 23 additions and 0 deletions

View File

@ -672,6 +672,9 @@ class View {
if (!$cache->inCache($internalPath)) {
$scanner = $storage->getScanner();
$scanner->scan($internalPath, Cache\Scanner::SCAN_SHALLOW);
} else {
$watcher = new \OC\Files\Cache\Watcher($storage);
$watcher->checkUpdate($internalPath);
}
$data = $cache->get($internalPath);
@ -711,6 +714,9 @@ class View {
if (!$cache->inCache($internalPath)) {
$scanner = $storage->getScanner();
$scanner->scan($internalPath, Cache\Scanner::SCAN_SHALLOW);
} else {
$watcher = new \OC\Files\Cache\Watcher($storage);
$watcher->checkUpdate($internalPath);
}
$files = $cache->getFolderContents($internalPath); //TODO: mimetype_filter

View File

@ -146,6 +146,23 @@ class View extends \PHPUnit_Framework_TestCase {
$this->assertEquals(3, count($folderView->searchByMime('text')));
}
function testWatcher() {
$storage1 = $this->getTestStorage();
\OC\Files\Filesystem::mount($storage1, array(), '/');
$rootView = new \OC\Files\View('');
$cachedData = $rootView->getFileInfo('foo.txt');
$this->assertEquals(16, $cachedData['size']);
$rootView->putFileInfo('foo.txt', array('mtime' => 10));
$storage1->file_put_contents('foo.txt', 'foo');
clearstatcache();
$cachedData = $rootView->getFileInfo('foo.txt');
$this->assertEquals(3, $cachedData['size']);
}
/**
* @param bool $scan
* @return \OC\Files\Storage\Storage