From fb1c0c85b00c48c3cbdd92003c3a6c126cd81dff Mon Sep 17 00:00:00 2001 From: Bradley Schofield Date: Tue, 24 Sep 2024 16:10:52 +0900 Subject: [PATCH] Handle missing database --- src/Appwrite/Platform/Workers/UsageDump.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/Appwrite/Platform/Workers/UsageDump.php b/src/Appwrite/Platform/Workers/UsageDump.php index bf53c2355b..e5d05bb2fb 100644 --- a/src/Appwrite/Platform/Workers/UsageDump.php +++ b/src/Appwrite/Platform/Workers/UsageDump.php @@ -214,12 +214,21 @@ class UsageDump extends Action case METRIC_DATABASE_LEVEL_STORAGE: Console::log('[' . DateTime::now() . '] Database Level Storage Calculation [' . $key . ']'); $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) { try { $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) { // Collection not found if ($e->getMessage() !== 'Collection not found') {