mirror of
https://github.com/appwrite/appwrite
synced 2026-05-24 09:28:40 +00:00
Handle missing database
This commit is contained in:
parent
001d13d7e9
commit
fb1c0c85b0
1 changed files with 11 additions and 2 deletions
|
|
@ -214,12 +214,21 @@ class UsageDump extends Action
|
||||||
case METRIC_DATABASE_LEVEL_STORAGE:
|
case METRIC_DATABASE_LEVEL_STORAGE:
|
||||||
Console::log('[' . DateTime::now() . '] Database Level Storage Calculation [' . $key . ']');
|
Console::log('[' . DateTime::now() . '] Database Level Storage Calculation [' . $key . ']');
|
||||||
$databaseInternalId = $data[0];
|
$databaseInternalId = $data[0];
|
||||||
$collections = $dbForProject->find('database_' . $databaseInternalId);
|
|
||||||
|
$collections = [];
|
||||||
|
try {
|
||||||
|
$collections = $dbForProject->find('database_' . $databaseInternalId);
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
// Database not found
|
||||||
|
if ($e->getMessage() !== 'Collection not found') {
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
foreach ($collections as $collection) {
|
foreach ($collections as $collection) {
|
||||||
try {
|
try {
|
||||||
$value += $dbForProject->getSizeOfCollection('database_'.$databaseInternalId.'_collection_'.$collection->getInternalId());
|
$value += $dbForProject->getSizeOfCollection('database_'.$databaseInternalId.'_collection_'.$collection->getInternalId());
|
||||||
$diskValue += $dbForProject->getSizeOfCollectionOnDisk('database_'.$databaseInternalId.'_collection_'.$collection->getInternalId());
|
$diskValue += $dbForProject->getSizeOfCollectionOnDisk('database_'.$databaseInternalId.'_collection_'.$collection->getInternalId());
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
// Collection not found
|
// Collection not found
|
||||||
if ($e->getMessage() !== 'Collection not found') {
|
if ($e->getMessage() !== 'Collection not found') {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue