You do not need to query the database directly. Have a look in this
function:
/**
* Calculate the disc space for the given path
*
* @param string $path
* @param \OCP\Files\FileInfo $rootInfo (optional)
* @return array
*/
public static function getStorageInfo($path, $rootInfo = null) {
// return storage info without adding mount points
$includeExtStorage =
\OC_Config::getValue('quota_include_external_storage', false);
if (!$rootInfo) {
$rootInfo = \OC\Files\Filesystem::getFileInfo($path,
false);
}
$used = $rootInfo->getSize();
if ($used < 0) {
$used = 0;
}
$quota = 0;
$storage = $rootInfo->getStorage();
if ($includeExtStorage &&
$storage->instanceOfStorage('\OC\Files\Storage\Shared')) {
$includeExtStorage = false;
}
if ($includeExtStorage) {
$quota =
OC_Util::getUserQuota(\OCP\User::getUser());
if ($quota !== \OC\Files\SPACE_UNLIMITED) {
// always get free space / total space from
root + mount points
$path = '';
return self::getGlobalStorageInfo();
}
}
// TODO: need a better way to get total space from storage
if
($storage->instanceOfStorage('\OC\Files\Storage\Wrapper\Quota')) {
$quota = $storage->getQuota();
}
$free = $storage->free_space('');
if ($free >= 0) {
$total = $free + $used;
} else {
$total = $free; //either unknown or unlimited
}
if ($total > 0) {
if ($quota > 0 && $total > $quota) {
$total = $quota;
}
// prevent division by zero or error codes (negative
values)
$relative = round(($used / $total) * 10000) / 100;
} else {
$relative = 0;
}
return array('free' => $free, 'used' => $used, 'total' =>
$total, 'relative' => $relative);
}
Cheers
Pierre
Von: [email protected] [mailto:[email protected]] Im
Auftrag von Ibai Ibai
Gesendet: Donnerstag, 18. Dezember 2014 15:36
An: [email protected]
Betreff: [owncloud-devel] Database table
Hi,
I would like to know how can I get the storage information in the database.
I mean, I want to know which is the maximum capacity of each user and how
much of that have they used.
I see that there is a table called oc_storages, but it have only the id and
the numeric_id...
Thank you very much in advance for the information.
_______________________________________________
Devel mailing list
[email protected]
http://mailman.owncloud.org/mailman/listinfo/devel