mirror of
https://github.com/zadam/trilium.git
synced 2026-08-31 04:15:49 +02:00
fix(standalone): sync crashing due to use of Buffer
This commit is contained in:
@@ -360,7 +360,7 @@ function getEntityChangeRow(entityChange: EntityChange) {
|
||||
|
||||
if (entityName === "blobs" && entityRow.content !== null) {
|
||||
if (typeof entityRow.content === "string") {
|
||||
entityRow.content = Buffer.from(entityRow.content, "utf-8");
|
||||
entityRow.content = binary_utils.encodeUtf8(entityRow.content);
|
||||
}
|
||||
|
||||
if (entityRow.content) {
|
||||
|
||||
@@ -6,6 +6,7 @@ import { getSql } from "./sql/index.js";
|
||||
import ws from "./ws.js";
|
||||
import { default as eventService } from "./events.js";
|
||||
import entity_constructor from "../becca/entity_constructor.js";
|
||||
import { decodeBase64 } from "./utils/binary.js";
|
||||
|
||||
interface UpdateContext {
|
||||
alreadyErased: number;
|
||||
@@ -119,7 +120,7 @@ function preProcessContent(remoteEC: EntityChange, remoteEntityRow: EntityRow) {
|
||||
// "string notes". The problem is that in general, it's not possible to detect whether a blob content
|
||||
// is string note or note (syncs can arrive out of order)
|
||||
if (typeof remoteEntityRow.content === "string") {
|
||||
remoteEntityRow.content = Buffer.from(remoteEntityRow.content, "base64");
|
||||
remoteEntityRow.content = decodeBase64(remoteEntityRow.content);
|
||||
|
||||
if (remoteEntityRow.content.byteLength === 0) {
|
||||
// there seems to be a bug which causes empty buffer to be stored as NULL which is then picked up as inconsistency
|
||||
|
||||
@@ -41,7 +41,7 @@ export function decodeUtf8(stringOrBuffer: string | Uint8Array) {
|
||||
}
|
||||
|
||||
export function encodeUtf8(string: string | Uint8Array) {
|
||||
return utf8Encoder.encode(wrapStringOrBuffer(string));
|
||||
return utf8Encoder.encode(unwrapStringOrBuffer(string));
|
||||
}
|
||||
|
||||
export function unwrapStringOrBuffer(stringOrBuffer: string | Uint8Array) {
|
||||
|
||||
Reference in New Issue
Block a user