fix(standalone): sync crashing due to use of Buffer

This commit is contained in:
Elian Doran
2026-03-22 21:18:39 +02:00
parent a8ea40b2e1
commit f5f11de58e
3 changed files with 4 additions and 3 deletions

View File

@@ -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) {

View File

@@ -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

View File

@@ -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) {