diff --git a/ReactNativeClient/lib/models/Resource.js b/ReactNativeClient/lib/models/Resource.js index 7070a4c5b..1a575505d 100644 --- a/ReactNativeClient/lib/models/Resource.js +++ b/ReactNativeClient/lib/models/Resource.js @@ -7,6 +7,7 @@ const { mime } = require('lib/mime-utils.js'); const { filename } = require('lib/path-utils.js'); const { FsDriverDummy } = require('lib/fs-driver-dummy.js'); const { markdownUtils } = require('lib/markdown-utils.js'); +const JoplinError = require('lib/JoplinError'); class Resource extends BaseItem { @@ -35,7 +36,7 @@ class Resource extends BaseItem { static async serialize(item, type = null, shownKeys = null) { let fieldNames = this.fieldNames(); - fieldNames.push('type_'); + fieldNames.push('type_'); //fieldNames = ArrayUtils.removeElement(fieldNames, 'encryption_blob_encrypted'); return super.serialize(item, 'resource', fieldNames); } @@ -92,7 +93,13 @@ class Resource extends BaseItem { const encryptedPath = this.fullPath(resource, true); if (resource.encryption_blob_encrypted) return { path: encryptedPath, resource: resource }; - await this.encryptionService().encryptFile(plainTextPath, encryptedPath); + + try { + await this.encryptionService().encryptFile(plainTextPath, encryptedPath); + } catch (error) { + if (error.code === 'ENOENT') throw new JoplinError('File not found:' + error.toString(), 'fileNotFound'); + throw error; + } const resourceCopy = Object.assign({}, resource); resourceCopy.encryption_blob_encrypted = 1;