1
0
Fork 0
mirror of synced 2024-10-02 10:16:27 +13:00

Merge pull request #8143 from appwrite/fix-catch-delete-errors

Catch DB errors on delete
This commit is contained in:
Jake Barnby 2024-05-17 17:21:06 +12:00 committed by GitHub
commit 2af7a5b2ee
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -679,9 +679,11 @@ class Deletes extends Action
$dbForProject = $getProjectDB($project);
$timeLimit = new TimeLimit("", 0, 1, $dbForProject);
$abuse = new Abuse($timeLimit);
$status = $abuse->cleanup($abuseRetention);
if (!$status) {
throw new Exception('Failed to delete Abuse logs for project ' . $projectId);
try {
$abuse->cleanup($abuseRetention);
} catch (DatabaseException $e) {
Console::error('Failed to delete abuse logs for project ' . $projectId . ': ' . $e->getMessage());
}
}
@ -697,9 +699,11 @@ class Deletes extends Action
$projectId = $project->getId();
$dbForProject = $getProjectDB($project);
$audit = new Audit($dbForProject);
$status = $audit->cleanup($auditRetention);
if (!$status) {
throw new Exception('Failed to delete Audit logs for project' . $projectId);
try {
$audit->cleanup($auditRetention);
} catch (DatabaseException $e) {
Console::error('Failed to delete audit logs for project ' . $projectId . ': ' . $e->getMessage());
}
}
@ -954,7 +958,12 @@ class Deletes extends Action
while ($sum === $limit) {
$chunk++;
$results = $database->find($collection, \array_merge([Query::limit($limit)], $queries));
try {
$results = $database->find($collection, [Query::limit($limit), ...$queries]);
} catch (DatabaseException $e) {
Console::error('Failed to find documents for collection ' . $collection . ': ' . $e->getMessage());
return;
}
$sum = count($results);