1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-06-15 23:00:36 +02:00

All: Optimised encryption and decryption of items so that it doesn't freeze the UI, especially on mobile

This commit is contained in:
Laurent Cozic
2018-06-25 18:14:57 +01:00
parent 84adf64271
commit fea83e28c4
5 changed files with 66 additions and 15 deletions

View File

@ -73,7 +73,12 @@ class Resource extends BaseItem {
}
try {
await this.encryptionService().decryptFile(encryptedPath, plainTextPath);
// const stat = await this.fsDriver().stat(encryptedPath);
await this.encryptionService().decryptFile(encryptedPath, plainTextPath, {
// onProgress: (progress) => {
// console.info('Decryption: ', progress.doneSize / stat.size);
// },
});
} catch (error) {
if (error.code === 'invalidIdentifier') {
// As the identifier is invalid it most likely means that this is not encrypted data
@ -108,7 +113,12 @@ class Resource extends BaseItem {
if (resource.encryption_blob_encrypted) return { path: encryptedPath, resource: resource };
try {
await this.encryptionService().encryptFile(plainTextPath, encryptedPath);
// const stat = await this.fsDriver().stat(plainTextPath);
await this.encryptionService().encryptFile(plainTextPath, encryptedPath, {
// onProgress: (progress) => {
// console.info(progress.doneSize / stat.size);
// },
});
} catch (error) {
if (error.code === 'ENOENT') throw new JoplinError('File not found:' + error.toString(), 'fileNotFound');
throw error;