mirror of
https://github.com/zadam/trilium.git
synced 2025-11-02 03:16:11 +01:00
Merge remote-tracking branch 'upstream/master' into feature/port_0.63.7
; Conflicts: ; package-lock.json ; src/routes/api/files.ts ; src/services/build.js ; src/services/notes.ts
This commit is contained in:
@@ -169,6 +169,8 @@ function saveAttachmentToTmpDir(req: Request) {
|
||||
return saveToTmpDir(fileName, content, 'attachments', attachment.attachmentId);
|
||||
}
|
||||
|
||||
const createdTemporaryFiles = new Set<string>();
|
||||
|
||||
function saveToTmpDir(fileName: string, content: string | Buffer, entityType: string, entityId: string) {
|
||||
const tmpObj = tmp.fileSync({ postfix: fileName });
|
||||
|
||||
@@ -180,6 +182,8 @@ function saveToTmpDir(fileName: string, content: string | Buffer, entityType: st
|
||||
|
||||
fs.closeSync(tmpObj.fd);
|
||||
|
||||
createdTemporaryFiles.add(tmpObj.name);
|
||||
|
||||
log.info(`Saved temporary file ${tmpObj.name}`);
|
||||
|
||||
if (utils.isElectron()) {
|
||||
@@ -203,6 +207,10 @@ function uploadModifiedFileToNote(req: Request) {
|
||||
const noteId = req.params.noteId;
|
||||
const {filePath} = req.body;
|
||||
|
||||
if (!createdTemporaryFiles.has(filePath)) {
|
||||
throw new ValidationError(`File '${filePath}' is not a temporary file.`);
|
||||
}
|
||||
|
||||
const note = becca.getNoteOrThrow(noteId);
|
||||
|
||||
log.info(`Updating note '${noteId}' with content from '${filePath}'`);
|
||||
|
||||
Reference in New Issue
Block a user