Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
fix(options/backup): size not showing due to intermediate state
Elian Dorana78db8c13795
diff --git a/apps/server/src/sql_provider.ts b/apps/server/src/sql_provider.tsindex fb29a2faa3..13427dd9bb 100644--- a/apps/server/src/sql_provider.ts+++ b/apps/server/src/sql_provider.ts@@ -38,12 +38,12 @@ export default class BetterSqlite3Provider implements DatabaseProvider {this.dbConnection = new Database(buffer, dbOpts);}- backup(destinationFile: string) {+ async backup(destinationFile: string) {try {unlinkSync(destinationFile);} catch (e) { } // unlink throws exception if the file did not exist- void this.dbConnection?.backup(destinationFile);+ await this.dbConnection?.backup(destinationFile);}prepare(query: string): Statement {diff --git a/packages/trilium-core/src/services/sql/types.ts b/packages/trilium-core/src/services/sql/types.tsindex 786c7e7bbf..2750312d15 100644--- a/packages/trilium-core/src/services/sql/types.ts+++ b/packages/trilium-core/src/services/sql/types.ts@@ -22,7 +22,8 @@ export interface DatabaseProvider {loadFromFile(path: string, isReadOnly: boolean): void;loadFromMemory(): void;loadFromBuffer(buffer: Uint8Array): void;- backup(destinationFile: string): void;+ /** Copies the database to the given file, resolving only once the copy has fully completed. */+ backup(destinationFile: string): void | Promise<void>;/*** Serialize the database to a byte array.* Optional - only implemented by browser-based providers.