small refactorings

This commit is contained in:
zadam
2023-06-29 22:10:13 +02:00
parent f4ec4e58c7
commit 48029cea7c
37 changed files with 95 additions and 155 deletions

View File

@@ -8,7 +8,7 @@ const cls = require('../services/cls');
const protectedSessionService = require('../services/protected_session');
const log = require('../services/log');
const utils = require('../services/utils');
const revisionService = require('./revisions.js');
const revisionService = require('./revisions');
const request = require('./request');
const path = require('path');
const url = require('url');
@@ -312,10 +312,17 @@ function protectNote(note, protect) {
for (const attachment of note.getAttachments()) {
if (protect !== attachment.isProtected) {
const content = attachment.getContent();
try {
const content = attachment.getContent();
attachment.isProtected = protect;
attachment.setContent(content, { forceSave: true });
attachment.isProtected = protect;
attachment.setContent(content, {forceSave: true});
}
catch (e) {
log.error(`Could not un/protect attachment '${attachment.attachmentId}'`);
throw e;
}
}
}
}