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(server): avoid saving invalid data (#4859)
liuyi01d7fe459745
diff --git a/packages/backend/server/src/modules/doc/manager.ts b/packages/backend/server/src/modules/doc/manager.tsindex fde40fa8e6..7f8de7b9f6 100644--- a/packages/backend/server/src/modules/doc/manager.ts+++ b/packages/backend/server/src/modules/doc/manager.ts@@ -32,6 +32,14 @@ function compare(yBinary: Buffer, jwstBinary: Buffer, strict = false): boolean {return compare(yBinary, yBinary2, true);}+function isEmptyBuffer(buf: Buffer): boolean {+ return (+ buf.length == 0 ||+ // 0x0000+ (buf.length === 2 && buf[0] === 0 && buf[1] === 0)+ );+}+const MAX_SEQ_NUM = 0x3fffffff; // u31/**@@ -377,6 +385,11 @@ export class DocManager implements OnModuleInit, OnModuleDestroy {) {const blob = Buffer.from(encodeStateAsUpdate(doc));const state = Buffer.from(encodeStateVector(doc));++ if (isEmptyBuffer(blob)) {+ return null;+ }+return this.db.snapshot.upsert({where: {id_workspaceId: {