diff options
author | Thomas Mueller <thomas.mueller@tmit.eu> | 2013-01-02 14:35:45 +0100 |
---|---|---|
committer | Thomas Mueller <thomas.mueller@tmit.eu> | 2013-01-02 14:35:45 +0100 |
commit | 2d36a20a1df4129608e9573cea3dcbb2e9de2d12 (patch) | |
tree | d0d767933a3ba4d8ef821c2554c3f4185749417a /lib | |
parent | 516464ba94a73e9151702ddd08dae1b7501dc79c (diff) | |
download | nextcloud-server-2d36a20a1df4129608e9573cea3dcbb2e9de2d12.tar.gz nextcloud-server-2d36a20a1df4129608e9573cea3dcbb2e9de2d12.zip |
moving storage calculation code to OC_Helper::getStorageInfo()
Diffstat (limited to 'lib')
-rw-r--r-- | lib/helper.php | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/lib/helper.php b/lib/helper.php index be4e4e52677..c870536eb52 100644 --- a/lib/helper.php +++ b/lib/helper.php @@ -758,4 +758,23 @@ class OC_Helper { } return $str; } + + /** + * Calculate the disc space + */ + public static function getStorageInfo() { + $rootInfo = OC_FileCache::get(''); + $used = $rootInfo['size']; + if ($used < 0) { + $used = 0; + } + $free = OC_Filesystem::free_space(); + $total = $free + $used; + if ($total == 0) { + $total = 1; // prevent division by zero + } + $relative = round(($used / $total) * 10000) / 100; + + return array('free' => $free, 'used' => $used, 'total' => $total, 'relative' => $relative); + } } |