Detect database corruption consistently

This commit is contained in:
Fedor Indutny 2021-09-08 13:39:14 -07:00 committed by GitHub
parent 1184098b42
commit 7510be0caf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 106 additions and 77 deletions

10
ts/sql/errors.ts Normal file
View file

@ -0,0 +1,10 @@
// Copyright 2021 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
export function isCorruptionError(error?: Error): boolean {
return (
error?.message?.includes('SQLITE_CORRUPT') ||
error?.message?.includes('database disk image is malformed') ||
false
);
}