本文整理汇总了PHP中OC\Files\Storage\Storage::getWatcher方法的典型用法代码示例。如果您正苦于以下问题:PHP Storage::getWatcher方法的具体用法?PHP Storage::getWatcher怎么用?PHP Storage::getWatcher使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OC\Files\Storage\Storage
的用法示例。
在下文中一共展示了Storage::getWatcher方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getWatcher
/**
* get a watcher instance for the cache
*
* @param string $path
* @param \OC\Files\Storage\Storage (optional) the storage to pass to the watcher
* @return \OC\Files\Cache\Watcher
*/
public function getWatcher($path = '', $storage = null)
{
if (!$storage) {
$storage = $this;
}
return $this->storage->getWatcher($path, $storage);
}
示例2: strlen
/**
* Tests that writing a file using the shared storage will propagate the file
* size to the owner's parent folders.
*/
function testSubFolderSizePropagationToOwnerStorage()
{
$initialSizes = self::getOwnerDirSizes('files/container/shareddir/subdir');
$textData = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
$dataLen = strlen($textData);
$this->sharedCache->put('subdir/bar.txt', array('mtime' => 10, 'storage_mtime' => 10, 'size' => $dataLen, 'mimetype' => 'text/plain'));
$this->sharedStorage->file_put_contents('subdir/bar.txt', $textData);
$this->sharedCache->put('subdir', array('mtime' => 10, 'storage_mtime' => 10, 'size' => $dataLen, 'mimetype' => 'text/plain'));
// run the propagation code
$result = $this->sharedStorage->getWatcher()->checkUpdate('subdir');
$this->assertTrue($result);
// the owner's parent dirs must have increase size
$newSizes = self::getOwnerDirSizes('files/container/shareddir/subdir');
$this->assertEquals($initialSizes[''] + $dataLen, $newSizes['']);
$this->assertEquals($initialSizes['files'] + $dataLen, $newSizes['files']);
$this->assertEquals($initialSizes['files/container'] + $dataLen, $newSizes['files/container']);
$this->assertEquals($initialSizes['files/container/shareddir'] + $dataLen, $newSizes['files/container/shareddir']);
$this->assertEquals($initialSizes['files/container/shareddir/subdir'] + $dataLen, $newSizes['files/container/shareddir/subdir']);
// no more updates
$result = $this->sharedStorage->getWatcher()->checkUpdate('subdir');
$this->assertFalse($result);
}
示例3: getCacheEntry
/**
* Get file info from cache
*
* If the file is not in cached it will be scanned
* If the file has changed on storage the cache will be updated
*
* @param \OC\Files\Storage\Storage $storage
* @param string $internalPath
* @param string $relativePath
* @return array|bool
*/
private function getCacheEntry($storage, $internalPath, $relativePath)
{
$cache = $storage->getCache($internalPath);
$data = $cache->get($internalPath);
$watcher = $storage->getWatcher($internalPath);
try {
// if the file is not in the cache or needs to be updated, trigger the scanner and reload the data
if (!$data || $data['size'] === -1) {
$this->lockFile($relativePath, ILockingProvider::LOCK_SHARED);
if (!$storage->file_exists($internalPath)) {
$this->unlockFile($relativePath, ILockingProvider::LOCK_SHARED);
return false;
}
$scanner = $storage->getScanner($internalPath);
$scanner->scan($internalPath, Cache\Scanner::SCAN_SHALLOW);
$data = $cache->get($internalPath);
$this->unlockFile($relativePath, ILockingProvider::LOCK_SHARED);
} else {
if (!Cache\Scanner::isPartialFile($internalPath) && $watcher->needsUpdate($internalPath, $data)) {
$this->lockFile($relativePath, ILockingProvider::LOCK_SHARED);
$watcher->update($internalPath, $data);
$storage->getPropagator()->propagateChange($internalPath, time());
$data = $cache->get($internalPath);
$this->unlockFile($relativePath, ILockingProvider::LOCK_SHARED);
}
}
} catch (LockedException $e) {
// if the file is locked we just use the old cache info
}
return $data;
}
示例4: getWatcher
/**
* get a watcher instance for the cache
*
* @param string $path
* @return \OC\Files\Cache\Watcher
*/
public function getWatcher($path = '')
{
return $this->storage->getWatcher($path);
}