1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-06-12 22:57:38 +02:00

All: Fixed issue with local resource needlessly marked as encrypted

This commit is contained in:
Laurent Cozic
2017-12-04 19:01:56 +00:00
parent f9634ea283
commit 685f541bb4
4 changed files with 45 additions and 8 deletions

View File

@ -76,10 +76,11 @@ class Resource extends BaseItem {
return super.save(decryptedItem, { autoTimestamp: false });
}
// Prepare the resource by encrypting it if needed.
// The call returns the path to the physical file AND the resource object
// which may have been modified. So the caller should update their copy with this.
// The call returns the path to the physical file AND a representation of the resource object
// as it should be uploaded to the sync target. Note that this may be different from what is stored
// in the database. In particular, the flag encryption_blob_encrypted might be 1 on the sync target
// if the resource is encrypted, but will be 0 locally because the device has the decrypted resource.
static async fullPathForSyncUpload(resource) {
const plainTextPath = this.fullPath(resource);
@ -93,10 +94,9 @@ class Resource extends BaseItem {
if (resource.encryption_blob_encrypted) return { path: encryptedPath, resource: resource };
await this.encryptionService().encryptFile(plainTextPath, encryptedPath);
resource.encryption_blob_encrypted = 1;
await Resource.save(resource, { autoTimestamp: false });
return { path: encryptedPath, resource: resource };
const resourceCopy = Object.assign({}, resource);
resourceCopy.encryption_blob_encrypted = 1;
return { path: encryptedPath, resource: resourceCopy };
}
static markdownTag(resource) {