Skip to content

Commit 5a316dd

Browse files
committed
Save external blobs during sync
1 parent 95d96f1 commit 5a316dd

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

apps/server/src/services/sync_update.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ import entityChangesService from "./entity_changes.js";
44
import eventService from "./events.js";
55
import entityConstructor from "../becca/entity_constructor.js";
66
import ws from "./ws.js";
7-
import type { EntityChange, EntityChangeRecord, EntityRow } from "@triliumnext/commons";
7+
import blobStorageService from "./blob-storage.js";
8+
import type { EntityChange, EntityChangeRecord, EntityRow, BlobRow } from "@triliumnext/commons";
89

910
interface UpdateContext {
1011
alreadyErased: number;
@@ -126,6 +127,14 @@ function preProcessContent(remoteEC: EntityChange, remoteEntityRow: EntityRow) {
126127
remoteEntityRow.content = "";
127128
}
128129
}
130+
131+
// store external blobs on this instance too
132+
const blobRow = remoteEntityRow as BlobRow;
133+
if (blobRow.contentLocation && blobRow.contentLocation !== "internal" && remoteEntityRow.content) {
134+
const newContentLocation = blobStorageService.saveExternal(blobRow.blobId, remoteEntityRow.content);
135+
blobRow.contentLocation = newContentLocation;
136+
blobRow.content = null;
137+
}
129138
}
130139
}
131140

0 commit comments

Comments
 (0)