Skip to content

Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.

Add hascolumn check for sqlite-blob pre-migrated clients (#2159)

Leendert de Borst1981b392b5b5
diff --git a/apps/browser-extension/src/utils/MultiManifestRendering.ts b/apps/browser-extension/src/utils/MultiManifestRendering.ts
index 78a5503b6..bcf791a4f 100644
--- a/apps/browser-extension/src/utils/MultiManifestRendering.ts
+++ b/apps/browser-extension/src/utils/MultiManifestRendering.ts
@@ -130,6 +130,14 @@ const subfolderRendering: MultiManifestRenderer = {
* @param sqliteClient - The open local vault
*/
displayNames(sqliteClient: SqliteClient): Record<string, string> {
+ /*
+ * A vault whose schema predates the manifest stamp holds nothing but the personal manifest, so it names none.
+ * This runs while migrating such a vault onto the current schema, where the column is not there yet.
+ */
+ if (!sqliteClient.hasColumn('Folders', 'ManifestId')) {
+ return {};
+ }
+
const roots = sqliteClient.executeQuery<{ ManifestId: string; Name: string }>('SELECT ManifestId, Name FROM Folders WHERE IsDeleted = 0 AND ManifestId IS NOT NULL AND UPPER(Id) = UPPER(ManifestId)');
return Object.fromEntries(roots.map(root => [root.ManifestId.toLowerCase(), root.Name]));
},
diff --git a/apps/browser-extension/src/utils/SqliteClient.ts b/apps/browser-extension/src/utils/SqliteClient.ts
index c07a7f2b6..03fa1ac15 100644
--- a/apps/browser-extension/src/utils/SqliteClient.ts
+++ b/apps/browser-extension/src/utils/SqliteClient.ts
@@ -322,6 +322,16 @@ export class SqliteClient implements IDatabaseClient {
}
}
+ /**
+ * Whether a table has a given column.
+ * @param table - Table name
+ * @param column - Column name
+ * @returns True when the table exists and has the column
+ */
+ public hasColumn(table: string, column: string): boolean {
+ return this.executeQuery<{ name: string }>('SELECT name FROM pragma_table_info(?) WHERE name = ?', [table, column]).length > 0;
+ }
+
/**
* Execute an INSERT, UPDATE, or DELETE query.
* @param query - SQL query string