1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-11-26 22:41:17 +02:00

All: Allow disabling encryption and added more test cases

This commit is contained in:
Laurent Cozic
2017-12-20 20:45:25 +01:00
parent cc02c1d585
commit 18846c11ed
9 changed files with 281 additions and 68 deletions

View File

@@ -81,10 +81,14 @@ class Resource extends BaseItem {
const plainTextPath = this.fullPath(resource);
if (!Setting.value('encryption.enabled')) {
if (resource.encryption_blob_encrypted) {
resource.encryption_blob_encrypted = 0;
await Resource.save(resource, { autoTimestamp: false });
}
// Sanity check - normally not possible
if (!!resource.encryption_blob_encrypted) throw new Error('Trying to access encrypted resource but encryption is currently disabled');
// // TODO: why is it set to 0 without decrypting first?
// if (resource.encryption_blob_encrypted) {
// resource.encryption_blob_encrypted = 0;
// await Resource.save(resource, { autoTimestamp: false });
// }
return { path: plainTextPath, resource: resource };
}