mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
server: Fix shadowed fields in becca entities
This commit is contained in:
parent
709101c540
commit
bb19cc216b
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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();
|
||||
|
@ -29,7 +29,6 @@ class BBranch extends AbstractBeccaEntity<BBranch> {
|
||||
prefix!: string | null;
|
||||
notePosition!: number;
|
||||
isExpanded!: boolean;
|
||||
utcDateModified?: string;
|
||||
|
||||
constructor(row?: BranchRow) {
|
||||
super();
|
||||
|
@ -14,7 +14,6 @@ class BOption extends AbstractBeccaEntity<BOption> {
|
||||
|
||||
name!: string;
|
||||
value!: string;
|
||||
isSynced!: boolean;
|
||||
|
||||
constructor(row?: OptionRow) {
|
||||
super();
|
||||
|
@ -15,7 +15,6 @@ class BRecentNote extends AbstractBeccaEntity<BRecentNote> {
|
||||
|
||||
noteId!: string;
|
||||
notePath!: string;
|
||||
utcDateCreated!: string;
|
||||
|
||||
constructor(row: RecentNoteRow) {
|
||||
super();
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user