本文整理汇总了PHP中OC\Files\Cache\Cache::correctFolderSize方法的典型用法代码示例。如果您正苦于以下问题:PHP Cache::correctFolderSize方法的具体用法?PHP Cache::correctFolderSize怎么用?PHP Cache::correctFolderSize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OC\Files\Cache\Cache
的用法示例。
在下文中一共展示了Cache::correctFolderSize方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testShallow
function testShallow() {
$this->fillTestFolders();
$this->scanner->scan('', \OC\Files\Cache\Scanner::SCAN_SHALLOW);
$this->assertEquals($this->cache->inCache(''), true);
$this->assertEquals($this->cache->inCache('foo.txt'), true);
$this->assertEquals($this->cache->inCache('foo.png'), true);
$this->assertEquals($this->cache->inCache('folder'), true);
$this->assertEquals($this->cache->inCache('folder/bar.txt'), false);
$cachedDataFolder = $this->cache->get('');
$cachedDataFolder2 = $this->cache->get('folder');
$this->assertEquals(-1, $cachedDataFolder['size']);
$this->assertEquals(-1, $cachedDataFolder2['size']);
$this->scanner->scan('folder', \OC\Files\Cache\Scanner::SCAN_SHALLOW);
$cachedDataFolder2 = $this->cache->get('folder');
$this->assertNotEquals($cachedDataFolder2['size'], -1);
$this->cache->correctFolderSize('folder');
$cachedDataFolder = $this->cache->get('');
$this->assertNotEquals($cachedDataFolder['size'], -1);
}
示例2: renameFromStorage
/**
* Rename a file or folder in the cache and update the size, etag and mtime of the parent folders
*
* @param IStorage $sourceStorage
* @param string $source
* @param string $target
*/
public function renameFromStorage(IStorage $sourceStorage, $source, $target)
{
if (!$this->enabled or Scanner::isPartialFile($source) or Scanner::isPartialFile($target)) {
return;
}
$time = time();
$sourceCache = $sourceStorage->getCache();
$sourceUpdater = $sourceStorage->getUpdater();
$sourcePropagator = $sourceStorage->getPropagator();
if ($sourceCache->inCache($source)) {
if ($this->cache->inCache($target)) {
$this->cache->remove($target);
}
if ($sourceStorage === $this->storage) {
$this->cache->move($source, $target);
} else {
$this->cache->moveFromCache($sourceCache, $source, $target);
}
}
if (pathinfo($source, PATHINFO_EXTENSION) !== pathinfo($target, PATHINFO_EXTENSION)) {
// handle mime type change
$mimeType = $this->storage->getMimeType($target);
$fileId = $this->cache->getId($target);
$this->cache->update($fileId, ['mimetype' => $mimeType]);
}
$sourceCache->correctFolderSize($source);
$this->cache->correctFolderSize($target);
if ($sourceUpdater instanceof Updater) {
$sourceUpdater->correctParentStorageMtime($source);
}
$this->correctParentStorageMtime($target);
$this->updateStorageMTimeOnly($target);
$sourcePropagator->propagateChange($source, $time);
$this->propagator->propagateChange($target, $time);
}
示例3: backgroundScan
/**
* walk over any folders that are not fully scanned yet and scan them
*/
public function backgroundScan()
{
$lastPath = null;
while (($path = $this->cache->getIncomplete()) !== false && $path !== $lastPath) {
$this->scan($path, self::SCAN_RECURSIVE, self::REUSE_ETAG);
$this->cache->correctFolderSize($path);
$lastPath = $path;
}
}
示例4: backgroundScan
/**
* walk over any folders that are not fully scanned yet and scan them
*/
public function backgroundScan() {
$lastPath = null;
while (($path = $this->cache->getIncomplete()) !== false && $path !== $lastPath) {
$this->scan($path, self::SCAN_RECURSIVE, self::REUSE_ETAG);
\OC_Hook::emit('Scanner', 'correctFolderSize', array('path' => $path));
if ($this->cacheActive) {
$this->cache->correctFolderSize($path);
}
$lastPath = $path;
}
}
示例5: update
/**
* Update the cache for changes to $path
*
* @param string $path
* @param ICacheEntry $cachedData
*/
public function update($path, $cachedData)
{
if ($this->storage->is_dir($path)) {
$this->scanner->scan($path, Scanner::SCAN_SHALLOW);
} else {
$this->scanner->scanFile($path);
}
if ($cachedData['mimetype'] === 'httpd/unix-directory') {
$this->cleanFolder($path);
}
$this->cache->correctFolderSize($path);
}
示例6: runBackgroundScanJob
private function runBackgroundScanJob(callable $callback, $path)
{
try {
$callback();
\OC_Hook::emit('Scanner', 'correctFolderSize', array('path' => $path));
if ($this->cacheActive && $this->cache instanceof Cache) {
$this->cache->correctFolderSize($path);
}
} catch (\OCP\Files\StorageInvalidException $e) {
// skip unavailable storages
} catch (\OCP\Files\StorageNotAvailableException $e) {
// skip unavailable storages
} catch (\OCP\Files\ForbiddenException $e) {
// skip forbidden storages
} catch (\OCP\Lock\LockedException $e) {
// skip unavailable storages
}
}
示例7: backgroundScan
/**
* walk over any folders that are not fully scanned yet and scan them
*/
public function backgroundScan()
{
$lastPath = null;
while (($path = $this->cache->getIncomplete()) !== false && $path !== $lastPath) {
try {
$this->scan($path, self::SCAN_RECURSIVE, self::REUSE_ETAG);
\OC_Hook::emit('Scanner', 'correctFolderSize', array('path' => $path));
if ($this->cacheActive) {
$this->cache->correctFolderSize($path);
}
} catch (\OCP\Files\StorageInvalidException $e) {
// skip unavailable storages
} catch (\OCP\Files\StorageNotAvailableException $e) {
// skip unavailable storages
} catch (\OCP\Lock\LockedException $e) {
// skip unavailable storages
}
// FIXME: this won't proceed with the next item, needs revamping of getIncomplete()
// to make this possible
$lastPath = $path;
}
}
示例8: correctFolderSize
/**
* update the folder size and the size of all parent folders
*
* @param string|boolean $path
* @param array $data (optional) meta data of the folder
*/
public function correctFolderSize($path, $data = null)
{
$this->cache->correctFolderSize($path, $data);
}