cache the storage info for 5 min
Signed-off-by: Robin Appelman <robin@icewind.nl>
This commit is contained in:
parent
5d486478d3
commit
e38a978623
|
@ -52,6 +52,7 @@ class OC_Helper {
|
|||
|
||||
/**
|
||||
* Creates an absolute url for public use
|
||||
*
|
||||
* @param string $service id
|
||||
* @param bool $add_slash
|
||||
* @return string the url
|
||||
|
@ -69,6 +70,7 @@ class OC_Helper {
|
|||
|
||||
/**
|
||||
* Make a human file size
|
||||
*
|
||||
* @param int $bytes file size in bytes
|
||||
* @return string a human readable file size
|
||||
*
|
||||
|
@ -104,6 +106,7 @@ class OC_Helper {
|
|||
|
||||
/**
|
||||
* Make a php file size
|
||||
*
|
||||
* @param int $bytes file size in bytes
|
||||
* @return string a php parseable file size
|
||||
*
|
||||
|
@ -130,6 +133,7 @@ class OC_Helper {
|
|||
|
||||
/**
|
||||
* Make a computer file size
|
||||
*
|
||||
* @param string $str file size in human readable format
|
||||
* @return float a file size in bytes
|
||||
*
|
||||
|
@ -172,6 +176,7 @@ class OC_Helper {
|
|||
|
||||
/**
|
||||
* Recursive copying of folders
|
||||
*
|
||||
* @param string $src source folder
|
||||
* @param string $dest target folder
|
||||
*
|
||||
|
@ -194,6 +199,7 @@ class OC_Helper {
|
|||
|
||||
/**
|
||||
* Recursive deletion of folders
|
||||
*
|
||||
* @param string $dir path to the folder
|
||||
* @param bool $deleteSelf if set to false only the content of the folder will be deleted
|
||||
* @return bool
|
||||
|
@ -393,6 +399,7 @@ class OC_Helper {
|
|||
|
||||
/**
|
||||
* performs a search in a nested array
|
||||
*
|
||||
* @param array $haystack the array to be searched
|
||||
* @param string $needle the search string
|
||||
* @param string $index optional, only search this key name
|
||||
|
@ -533,6 +540,11 @@ class OC_Helper {
|
|||
* @throws \OCP\Files\NotFoundException
|
||||
*/
|
||||
public static function getStorageInfo($path, $rootInfo = null) {
|
||||
$memcache = \OC::$server->getMemCacheFactory()->create('storageInfo');
|
||||
$cached = $memcache->get($rootInfo ? '__root__' : $path);
|
||||
if (is_array($cached)) {
|
||||
return $cached;
|
||||
}
|
||||
// return storage info without adding mount points
|
||||
$includeExtStorage = \OC::$server->getSystemConfig()->getValue('quota_include_external_storage', false);
|
||||
|
||||
|
@ -601,6 +613,16 @@ class OC_Helper {
|
|||
$ownerDisplayName = $owner->getDisplayName();
|
||||
}
|
||||
|
||||
$memcache->set($rootInfo ? '__root__' : $path, [
|
||||
'free' => $free,
|
||||
'used' => $used,
|
||||
'quota' => $quota,
|
||||
'total' => $total,
|
||||
'relative' => $relative,
|
||||
'owner' => $ownerId,
|
||||
'ownerDisplayName' => $ownerDisplayName,
|
||||
], 5 * 60);
|
||||
|
||||
return [
|
||||
'free' => $free,
|
||||
'used' => $used,
|
||||
|
@ -645,6 +667,7 @@ class OC_Helper {
|
|||
|
||||
/**
|
||||
* Returns whether the config file is set manually to read-only
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function isReadOnlyConfigEnabled() {
|
||||
|
|
Loading…
Reference in New Issue