1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-07-16 00:14:34 +02:00

Electron: E2EE config

This commit is contained in:
Laurent Cozic
2017-12-24 09:36:31 +01:00
parent d13c2cf8d7
commit d1abf4971d
7 changed files with 206 additions and 37 deletions

View File

@ -346,6 +346,37 @@ class BaseItem extends BaseModel {
return output;
}
static async encryptedItemsStats() {
const classNames = this.encryptableItemClassNames();
let encryptedCount = 0;
let totalCount = 0;
for (let i = 0; i < classNames.length; i++) {
const ItemClass = this.getClass(classNames[i]);
encryptedCount += await ItemClass.count({ where: 'encryption_applied = 1' });
totalCount += await ItemClass.count();
}
return {
encrypted: encryptedCount,
total: totalCount,
};
}
static async encryptedItemsCount() {
const classNames = this.encryptableItemClassNames();
let output = 0;
for (let i = 0; i < classNames.length; i++) {
const className = classNames[i];
const ItemClass = this.getClass(className);
const count = await ItemClass.count({ where: 'encryption_applied = 1' });
output += count;
}
return output;
}
static async hasEncryptedItems() {
const classNames = this.encryptableItemClassNames();

View File

@ -280,16 +280,11 @@ class EncryptionService {
await destination.append(this.encodeHeader_(header));
let fromIndex = 0;
while (true) {
const block = await source.read(this.chunkSize_);
if (!block) break;
fromIndex += block.length;
const encrypted = await this.encrypt(method, masterKeyPlainText, block);
await destination.append(padLeft(encrypted.length.toString(16), 6, '0'));
await destination.append(encrypted);
}