mirror of
https://github.com/zadam/trilium.git
synced 2025-06-06 18:08:33 +02:00
fix protecting attachments
This commit is contained in:
parent
3a83d58b25
commit
83f19c0537
4
package-lock.json
generated
4
package-lock.json
generated
@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "trilium",
|
"name": "trilium",
|
||||||
"version": "0.61.5-beta",
|
"version": "0.61.6-beta",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "trilium",
|
"name": "trilium",
|
||||||
"version": "0.61.5-beta",
|
"version": "0.61.6-beta",
|
||||||
"hasInstallScript": true,
|
"hasInstallScript": true,
|
||||||
"license": "AGPL-3.0-only",
|
"license": "AGPL-3.0-only",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
@ -98,7 +98,12 @@ class BAttachment extends AbstractBeccaEntity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
decrypt() {
|
decrypt() {
|
||||||
if (this.isProtected && !this.isDecrypted && protectedSessionService.isProtectedSessionAvailable()) {
|
if (!this.isProtected || !this.attachmentId) {
|
||||||
|
this.isDecrypted = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!this.isDecrypted && protectedSessionService.isProtectedSessionAvailable()) {
|
||||||
try {
|
try {
|
||||||
this.title = protectedSessionService.decryptString(this.title);
|
this.title = protectedSessionService.decryptString(this.title);
|
||||||
this.isDecrypted = true;
|
this.isDecrypted = true;
|
||||||
|
@ -14,21 +14,34 @@ function protectRevisions(note) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (const revision of note.getRevisions()) {
|
for (const revision of note.getRevisions()) {
|
||||||
if (note.isProtected === revision.isProtected) {
|
if (note.isProtected !== revision.isProtected) {
|
||||||
continue;
|
try {
|
||||||
|
const content = revision.getContent();
|
||||||
|
|
||||||
|
revision.isProtected = note.isProtected;
|
||||||
|
|
||||||
|
// this will force de/encryption
|
||||||
|
revision.setContent(content, {forceSave: true});
|
||||||
|
} catch (e) {
|
||||||
|
log.error(`Could not un/protect note revision '${revision.revisionId}'`);
|
||||||
|
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
for (const attachment of revision.getAttachments()) {
|
||||||
const content = revision.getContent();
|
if (note.isProtected !== attachment.isProtected) {
|
||||||
|
try {
|
||||||
|
const content = attachment.getContent();
|
||||||
|
|
||||||
revision.isProtected = note.isProtected;
|
attachment.isProtected = note.isProtected;
|
||||||
|
attachment.setContent(content, {forceSave: true});
|
||||||
|
} catch (e) {
|
||||||
|
log.error(`Could not un/protect attachment '${attachment.attachmentId}'`);
|
||||||
|
|
||||||
// this will force de/encryption
|
throw e;
|
||||||
revision.setContent(content, {forceSave: true});
|
}
|
||||||
} catch (e) {
|
}
|
||||||
log.error(`Could not un/protect note revision '${revision.revisionId}'`);
|
|
||||||
|
|
||||||
throw e;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user