1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-11-29 22:48:10 +02:00

Revert "Applied prettier to code base"

This reverts commit c4f19465a6.
This commit is contained in:
Laurent Cozic
2018-03-09 20:59:12 +00:00
parent 5e8b09f5af
commit 55c5ddedf4
203 changed files with 7883 additions and 13355 deletions

View File

@@ -1,12 +1,13 @@
const BaseItem = require("lib/models/BaseItem");
const { Logger } = require("lib/logger.js");
const BaseItem = require('lib/models/BaseItem');
const { Logger } = require('lib/logger.js');
class DecryptionWorker {
constructor() {
this.state_ = "idle";
this.state_ = 'idle';
this.logger_ = new Logger();
this.dispatch = action => {
this.dispatch = (action) => {
//console.warn('DecryptionWorker.dispatch is not defined');
};
@@ -32,7 +33,7 @@ class DecryptionWorker {
}
encryptionService() {
if (!this.encryptionService_) throw new Error("DecryptionWorker.encryptionService_ is not set!!");
if (!this.encryptionService_) throw new Error('DecryptionWorker.encryptionService_ is not set!!');
return this.encryptionService_;
}
@@ -42,23 +43,23 @@ class DecryptionWorker {
this.scheduleId_ = setTimeout(() => {
this.scheduleId_ = null;
this.start({
materKeyNotLoadedHandler: "dispatch",
materKeyNotLoadedHandler: 'dispatch',
});
}, 1000);
}
async start(options = null) {
if (options === null) options = {};
if (!("materKeyNotLoadedHandler" in options)) options.materKeyNotLoadedHandler = "throw";
if (!('materKeyNotLoadedHandler' in options)) options.materKeyNotLoadedHandler = 'throw';
if (this.state_ !== "idle") {
if (this.state_ !== 'idle') {
this.logger().info('DecryptionWorker: cannot start because state is "' + this.state_ + '"');
return;
}
this.logger().info("DecryptionWorker: starting decryption...");
this.logger().info('DecryptionWorker: starting decryption...');
this.state_ = "started";
this.state_ = 'started';
let excludedIds = [];
@@ -79,18 +80,18 @@ class DecryptionWorker {
// }
const ItemClass = BaseItem.itemClass(item);
// Don't log in production as it results in many messages when importing many items
// this.logger().info('DecryptionWorker: decrypting: ' + item.id + ' (' + ItemClass.tableName() + ')');
try {
await ItemClass.decrypt(item);
} catch (error) {
excludedIds.push(item.id);
if (error.code === "masterKeyNotLoaded" && options.materKeyNotLoadedHandler === "dispatch") {
if (error.code === 'masterKeyNotLoaded' && options.materKeyNotLoadedHandler === 'dispatch') {
if (notLoadedMasterKeyDisptaches.indexOf(error.masterKeyId) < 0) {
this.dispatch({
type: "MASTERKEY_ADD_NOT_LOADED",
type: 'MASTERKEY_ADD_NOT_LOADED',
id: error.masterKeyId,
});
notLoadedMasterKeyDisptaches.push(error.masterKeyId);
@@ -98,26 +99,27 @@ class DecryptionWorker {
continue;
}
if (error.code === "masterKeyNotLoaded" && options.materKeyNotLoadedHandler === "throw") {
if (error.code === 'masterKeyNotLoaded' && options.materKeyNotLoadedHandler === 'throw') {
throw error;
}
this.logger().warn("DecryptionWorker: error for: " + item.id + " (" + ItemClass.tableName() + ")", error);
this.logger().warn('DecryptionWorker: error for: ' + item.id + ' (' + ItemClass.tableName() + ')', error);
}
}
if (!result.hasMore) break;
}
} catch (error) {
this.logger().error("DecryptionWorker:", error);
this.state_ = "idle";
this.logger().error('DecryptionWorker:', error);
this.state_ = 'idle';
throw error;
}
this.logger().info("DecryptionWorker: completed decryption.");
this.logger().info('DecryptionWorker: completed decryption.');
this.state_ = "idle";
this.state_ = 'idle';
}
}
module.exports = DecryptionWorker;
module.exports = DecryptionWorker;