当前位置: 首页>>代码示例>>PHP>>正文


PHP Storage::getWatcher方法代码示例

本文整理汇总了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);
 }
开发者ID:GitHubUser4234,项目名称:core,代码行数:14,代码来源:Wrapper.php

示例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);
 }
开发者ID:Romua1d,项目名称:core,代码行数:26,代码来源:watcher.php

示例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;
 }
开发者ID:drognisep,项目名称:Portfolio-Site,代码行数:42,代码来源:View.php

示例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);
 }
开发者ID:hjimmy,项目名称:owncloud,代码行数:10,代码来源:wrapper.php


注:本文中的OC\Files\Storage\Storage::getWatcher方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。