Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

web: better handling of `database disk image is malformed` error

Abdullah Attae722866d62da
diff --git a/apps/web/src/components/error-boundary/index.tsx b/apps/web/src/components/error-boundary/index.tsx
index bd3aa3121..ad0cd7934 100644
--- a/apps/web/src/components/error-boundary/index.tsx
+++ b/apps/web/src/components/error-boundary/index.tsx
@@ -162,9 +162,9 @@ function getErrorHelp(props: FallbackProps) {
if (
errorText.includes("file is not a database") ||
errorText.includes("unsupported file format") ||
- errorText.includes("database disk image is malformed") ||
errorText.includes("null function or function signature mismatch") ||
- errorText.includes("malformed database schema")
+ errorText.includes("malformed database schema") ||
+ /table ".+?" already exists/.test(errorText)
) {
return {
explanation: `This error usually means the database file is either corrupt or it could not be decrypted.`,
@@ -195,6 +195,17 @@ function getErrorHelp(props: FallbackProps) {
resetErrorBoundary();
}
};
+ } else if (errorText.includes("database disk image is malformed")) {
+ return {
+ explanation: `This error usually means the search index is corrupted.`,
+ action:
+ "This error can be fixed by rebuilding the search index. This action won't result in any kind of data loss.",
+ fix: async () => {
+ const { db } = await import("../../common/db");
+ await db.lookup.rebuild();
+ resetErrorBoundary();
+ }
+ };
}
}