Skip to content

Build your personal knowledge base with Trilium Notes

Merge remote-tracking branch 'upstream/master' into feature/port_0.63.7

Elian Dorand5c1bd108595
diff --cc src/routes/api/files.ts
index df8f14b589,ee4e5c884d..3bb269f7d7
--- a/src/routes/api/files.ts
+++ b/src/routes/api/files.ts
@@@ -169,17 -154,16 +169,21 @@@ function saveAttachmentToTmpDir(req: Re
return saveToTmpDir(fileName, content, 'attachments', attachment.attachmentId);
}
-const createdTemporaryFiles = new Set();
++const createdTemporaryFiles = new Set<string>();
+
-function saveToTmpDir(fileName, content, entityType, entityId) {
+function saveToTmpDir(fileName: string, content: string | Buffer, entityType: string, entityId: string) {
const tmpObj = tmp.fileSync({ postfix: fileName });
- fs.writeSync(tmpObj.fd, content);
+ if (typeof content === "string") {
+ fs.writeSync(tmpObj.fd, content);
+ } else {
+ fs.writeSync(tmpObj.fd, content);
+ }
+
fs.closeSync(tmpObj.fd);
+ createdTemporaryFiles.add(tmpObj.name);
+
log.info(`Saved temporary file ${tmpObj.name}`);
if (utils.isElectron()) {
diff --cc src/services/build.ts
index b392adba08,0000000000..a4c7df2d13
mode 100644,000000..100644
--- a/src/services/build.ts
+++ b/src/services/build.ts
@@@ -1,1 -1,0 +1,1 @@@
- export = { buildDate:"2024-03-28T07:11:39+01:00", buildRevision: "399458b52f250b22be22d980a78de0b3390d7521" };
++export = { buildDate:"2024-05-18T06:17:21+02:00", buildRevision: "c7f19e04fafc031910f6f9a45d2015387618e902" };
diff --cc src/services/notes.ts
index a60799e80e,581811863e..2e099392e2
--- a/src/services/notes.ts
+++ b/src/services/notes.ts
@@@ -445,14 -457,19 +445,18 @@@ function findIncludeNoteLinks(content:
return content;
}
-function findRelationMapLinks(content, foundLinks) {
+function findRelationMapLinks(content: string, foundLinks: FoundLink[]) {
- const obj = JSON.parse(content);
+ try {
+ const obj = JSON.parse(content);
- for (const note of obj.notes) {
- foundLinks.push({
- name: 'relationMapLink',
- value: note.noteId
- });
+ for (const note of obj.notes) {
+ foundLinks.push({
+ name: 'relationMapLink',
+ value: note.noteId
+ });
+ }
- }
- catch (e) {
++ } catch (e: any) {
+ log.error("Could not scan for relation map links: " + e.message);
}
}