Skip to content

Build your personal knowledge base with Trilium Notes

server: Fix shadowed fields in becca entities

Elian Doranbb19cc216b39
diff --git a/src/becca/becca-interface.ts b/src/becca/becca-interface.ts
index f719a9f024..c5e9f6925e 100644
--- a/src/becca/becca-interface.ts
+++ b/src/becca/becca-interface.ts
@@ -8,7 +8,7 @@ import BAttribute from "./entities/battribute.js";
import BBranch from "./entities/bbranch.js";
import BRevision from "./entities/brevision.js";
import BAttachment from "./entities/battachment.js";
-import { AttachmentRow, RevisionRow } from './entities/rows.js';
+import { AttachmentRow, BlobRow, RevisionRow } from './entities/rows.js';
import BBlob from "./entities/bblob.js";
import BRecentNote from "./entities/brecent_note.js";
import AbstractBeccaEntity from "./entities/abstract_becca_entity.js";
@@ -199,7 +199,7 @@ export default class Becca {
return null;
}
- const row = sql.getRow<BBlob | null>("SELECT *, LENGTH(content) AS contentLength FROM blobs WHERE blobId = ?", [entity.blobId]);
+ const row = sql.getRow<BlobRow | null>("SELECT *, LENGTH(content) AS contentLength FROM blobs WHERE blobId = ?", [entity.blobId]);
return row ? new BBlob(row) : null;
}
diff --git a/src/becca/entities/battachment.ts b/src/becca/entities/battachment.ts
index 83b76bec8c..ab90d345f2 100644
--- a/src/becca/entities/battachment.ts
+++ b/src/becca/entities/battachment.ts
@@ -44,9 +44,6 @@ class BAttachment extends AbstractBeccaEntity<BAttachment> {
title!: string;
type?: keyof typeof attachmentRoleToNoteTypeMapping;
position?: number;
- blobId?: string;
- isProtected?: boolean;
- dateModified?: string;
utcDateScheduledForErasureSince?: string | null;
/** optionally added to the entity */
contentLength?: number;
diff --git a/src/becca/entities/bblob.ts b/src/becca/entities/bblob.ts
index d406831f09..7ce94eb2e0 100644
--- a/src/becca/entities/bblob.ts
+++ b/src/becca/entities/bblob.ts
@@ -7,11 +7,8 @@ class BBlob extends AbstractBeccaEntity<BBlob> {
static get primaryKeyName() { return "blobId"; }
static get hashedProperties() { return ["blobId", "content"]; }
- blobId!: string;
content!: string | Buffer;
contentLength!: number;
- dateModified!: string;
- utcDateModified!: string;
constructor(row: BlobRow) {
super();
diff --git a/src/becca/entities/bbranch.ts b/src/becca/entities/bbranch.ts
index 6fc2c6ece9..daa71f9177 100644
--- a/src/becca/entities/bbranch.ts
+++ b/src/becca/entities/bbranch.ts
@@ -29,7 +29,6 @@ class BBranch extends AbstractBeccaEntity<BBranch> {
prefix!: string | null;
notePosition!: number;
isExpanded!: boolean;
- utcDateModified?: string;
constructor(row?: BranchRow) {
super();
diff --git a/src/becca/entities/boption.ts b/src/becca/entities/boption.ts
index 4c577cdd6d..4ae5ba7a98 100644
--- a/src/becca/entities/boption.ts
+++ b/src/becca/entities/boption.ts
@@ -14,7 +14,6 @@ class BOption extends AbstractBeccaEntity<BOption> {
name!: string;
value!: string;
- isSynced!: boolean;
constructor(row?: OptionRow) {
super();
diff --git a/src/becca/entities/brecent_note.ts b/src/becca/entities/brecent_note.ts
index 414addfad4..f9f31a98fd 100644
--- a/src/becca/entities/brecent_note.ts
+++ b/src/becca/entities/brecent_note.ts
@@ -15,7 +15,6 @@ class BRecentNote extends AbstractBeccaEntity<BRecentNote> {
noteId!: string;
notePath!: string;
- utcDateCreated!: string;
constructor(row: RecentNoteRow) {
super();
diff --git a/src/becca/entities/brevision.ts b/src/becca/entities/brevision.ts
index 4aa64fd610..7448416abe 100644
--- a/src/becca/entities/brevision.ts
+++ b/src/becca/entities/brevision.ts
@@ -33,13 +33,9 @@ class BRevision extends AbstractBeccaEntity<BRevision> {
noteId!: string;
type!: string;
mime!: string;
- isProtected!: boolean;
title!: string;
- blobId?: string;
dateLastEdited?: string;
- dateCreated!: string;
utcDateLastEdited?: string;
- utcDateCreated!: string;
contentLength?: number;
content?: string | Buffer;
diff --git a/src/routes/api/revisions.ts b/src/routes/api/revisions.ts
index b250e8ec0e..7e98318d5c 100644
--- a/src/routes/api/revisions.ts
+++ b/src/routes/api/revisions.ts
@@ -64,6 +64,10 @@ function getRevision(req: Request) {
function getRevisionFilename(revision: BRevision) {
let filename = utils.formatDownloadTitle(revision.title, revision.type, revision.mime);
+ if (!revision.dateCreated) {
+ throw new Error("Missing creation date for revision.");
+ }
+
const extension = path.extname(filename);
const date = revision.dateCreated
.substr(0, 19)