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


PHP Cache::calculateFolderSize方法代码示例

本文整理汇总了PHP中OC\Files\Cache\Cache::calculateFolderSize方法的典型用法代码示例。如果您正苦于以下问题:PHP Cache::calculateFolderSize方法的具体用法?PHP Cache::calculateFolderSize怎么用?PHP Cache::calculateFolderSize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在OC\Files\Cache\Cache的用法示例。


在下文中一共展示了Cache::calculateFolderSize方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: calculateFolderSize

 /**
  * get the size of a folder and set it in the cache
  *
  * @param string $path
  * @param array $entry (optional) meta data of the folder
  * @return int
  */
 public function calculateFolderSize($path, $entry = null)
 {
     if ($path !== '/' and $path !== '' and $path !== 'files' and $path !== 'files_trashbin' and $path !== 'files_versions') {
         return parent::calculateFolderSize($path, $entry);
     } elseif ($path === '' or $path === '/') {
         // since the size of / isn't used (the size of /files is used instead) there is no use in calculating it
         return 0;
     }
     $totalSize = 0;
     if (is_null($entry)) {
         $entry = $this->get($path);
     }
     if ($entry && $entry['mimetype'] === 'httpd/unix-directory') {
         $id = $entry['fileid'];
         $sql = 'SELECT SUM(`size`) AS f1 ' . 'FROM `*PREFIX*filecache` ' . 'WHERE `parent` = ? AND `storage` = ? AND `size` >= 0';
         $result = \OC_DB::executeAudited($sql, array($id, $this->getNumericStorageId()));
         if ($row = $result->fetchRow()) {
             $result->closeCursor();
             list($sum) = array_values($row);
             $totalSize = 0 + $sum;
             $entry['size'] += 0;
             if ($entry['size'] !== $totalSize) {
                 $this->update($id, array('size' => $totalSize));
             }
         }
     }
     return $totalSize;
 }
开发者ID:kenwi,项目名称:core,代码行数:35,代码来源:homecache.php

示例2: testRootFolderSizeForNonHomeStorage

	public function testRootFolderSizeForNonHomeStorage() {
		$dir1 = 'knownsize';
		$dir2 = 'unknownsize';
		$fileData = array();
		$fileData[''] = array('size' => -1, 'mtime' => 20, 'mimetype' => 'httpd/unix-directory');
		$fileData[$dir1] = array('size' => 1000, 'mtime' => 20, 'mimetype' => 'httpd/unix-directory');
		$fileData[$dir2] = array('size' => -1, 'mtime' => 25, 'mimetype' => 'httpd/unix-directory');

		$this->cache->put('', $fileData['']);
		$this->cache->put($dir1, $fileData[$dir1]);
		$this->cache->put($dir2, $fileData[$dir2]);

		$this->assertTrue($this->cache->inCache($dir1));
		$this->assertTrue($this->cache->inCache($dir2));

		// check that root size ignored the unknown sizes
		$this->assertEquals(-1, $this->cache->calculateFolderSize(''));

		// clean up
		$this->cache->remove('');
		$this->cache->remove($dir1);
		$this->cache->remove($dir2);

		$this->assertFalse($this->cache->inCache($dir1));
		$this->assertFalse($this->cache->inCache($dir2));
	}
开发者ID:ninjasilicon,项目名称:core,代码行数:26,代码来源:cache.php

示例3: calculateFolderSize

 /**
  * get the size of a folder and set it in the cache
  *
  * @param string $path
  * @param array $entry (optional) meta data of the folder
  * @return int
  */
 public function calculateFolderSize($path, $entry = null)
 {
     return $this->cache->calculateFolderSize($path, $entry);
 }
开发者ID:kebenxiaoming,项目名称:owncloudRedis,代码行数:11,代码来源:cachewrapper.php


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