There can be more than Notion and Miro. AFFiNE(pronounced [ə‘fain]) is a next-gen knowledge base that brings planning, sorting and creating all together. Privacy first, open-source, customizable and ready to use.
TypeScript appcrdteditorelectronknowledge-basemarkdownmironotesnotionnotion-alternativerustrust-langrust-languagetabletableviewwhiteboardwikiworkspace
fix(electron): only update db after data changed (#5226)
Joooye_34761c3c2551d6
diff --git a/packages/frontend/electron/src/helper/db/migration.ts b/packages/frontend/electron/src/helper/db/migration.tsindex d6cb90f199..393b0f76b4 100644--- a/packages/frontend/electron/src/helper/db/migration.ts+++ b/packages/frontend/electron/src/helper/db/migration.ts@@ -1,4 +1,3 @@-import { equal } from 'node:assert';import { resolve } from 'node:path';import { SqliteConnection } from '@affine/native';@@ -78,19 +77,23 @@ export const migrateToLatest = async (};await downloadBinary(rootDoc, true);const result = await forceUpgradePages(rootDoc, schema);- equal(result, true, 'migrateWorkspace should return boolean value');- const uploadBinary = async (doc: YDoc, isRoot: boolean) => {- await connection.replaceUpdates(doc.guid, [- { docId: isRoot ? undefined : doc.guid, data: encodeStateAsUpdate(doc) },- ]);- // connection..applyUpdate(encodeStateAsUpdate(doc), 'self', doc.guid)- await Promise.all(- [...doc.subdocs].map(subdoc => {- return uploadBinary(subdoc, false);- })- );- };- await uploadBinary(rootDoc, true);+ if (result) {+ const uploadBinary = async (doc: YDoc, isRoot: boolean) => {+ await connection.replaceUpdates(doc.guid, [+ {+ docId: isRoot ? undefined : doc.guid,+ data: encodeStateAsUpdate(doc),+ },+ ]);+ // connection..applyUpdate(encodeStateAsUpdate(doc), 'self', doc.guid)+ await Promise.all(+ [...doc.subdocs].map(subdoc => {+ return uploadBinary(subdoc, false);+ })+ );+ };+ await uploadBinary(rootDoc, true);+ }await connection.close();};