當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。