1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-12-23 23:33:01 +02:00

Applied prettier to code base

This commit is contained in:
Laurent Cozic
2018-03-09 17:49:35 +00:00
parent e868102c98
commit c4f19465a6
203 changed files with 13395 additions and 7927 deletions

View File

@@ -1,12 +1,12 @@
const { time } = require('lib/time-utils.js');
const { basicDelta } = require('lib/file-api');
const { time } = require("lib/time-utils.js");
const { basicDelta } = require("lib/file-api");
// NOTE: when synchronising with the file system the time resolution is the second (unlike milliseconds for OneDrive for instance).
// What it means is that if, for example, client 1 changes a note at time t, and client 2 changes the same note within the same second,
// both clients will not know about each others updates during the next sync. They will simply both sync their note and whoever
// comes last will overwrite (on the remote storage) the note of the other client. Both client will then have a different note at
// that point and that will only be resolved if one of them changes the note and sync (if they don't change it, it will never get resolved).
//
//
// This is compound with the fact that we can't have a reliable delta API on the file system so we need to check all the timestamps
// every time and rely on this exclusively to know about changes.
//
@@ -15,17 +15,16 @@ const { basicDelta } = require('lib/file-api');
// will have been modified at the same exact second at some point. If not, it's another bug that needs to be investigated.
class FileApiDriverLocal {
fsErrorToJsError_(error, path = null) {
let msg = error.toString();
if (path !== null) msg += '. Path: ' + path;
if (path !== null) msg += ". Path: " + path;
let output = new Error(msg);
if (error.code) output.code = error.code;
return output;
}
fsDriver() {
if (!FileApiDriverLocal.fsDriver_) throw new Error('FileApiDriverLocal.fsDriver_ not set!');
if (!FileApiDriverLocal.fsDriver_) throw new Error("FileApiDriverLocal.fsDriver_ not set!");
return FileApiDriverLocal.fsDriver_;
}
@@ -66,7 +65,7 @@ class FileApiDriverLocal {
}
async delta(path, options) {
const getStatFn = async (path) => {
const getStatFn = async path => {
const stats = await this.fsDriver().readDirStats(path);
return this.metadataFromStats_(stats);
};
@@ -74,7 +73,7 @@ class FileApiDriverLocal {
try {
const output = await basicDelta(path, getStatFn, options);
return output;
} catch(error) {
} catch (error) {
throw this.fsErrorToJsError_(error, path);
}
}
@@ -89,7 +88,7 @@ class FileApiDriverLocal {
hasMore: false,
context: null,
};
} catch(error) {
} catch (error) {
throw this.fsErrorToJsError_(error, path);
}
}
@@ -98,7 +97,7 @@ class FileApiDriverLocal {
let output = null;
try {
if (options.target === 'file') {
if (options.target === "file") {
//output = await fs.copy(path, options.path, { overwrite: true });
output = await this.fsDriver().copy(path, options.path);
} else {
@@ -106,7 +105,7 @@ class FileApiDriverLocal {
output = await this.fsDriver().readFile(path, options.encoding);
}
} catch (error) {
if (error.code == 'ENOENT') return null;
if (error.code == "ENOENT") return null;
throw this.fsErrorToJsError_(error, path);
}
@@ -128,7 +127,7 @@ class FileApiDriverLocal {
// resolve();
// return;
// }
// fs.mkdirp(path, (error) => {
// if (error) {
// reject(this.fsErrorToJsError_(error));
@@ -144,12 +143,12 @@ class FileApiDriverLocal {
if (!options) options = {};
try {
if (options.source === 'file') {
if (options.source === "file") {
await this.fsDriver().copy(options.path, path);
return;
}
await this.fsDriver().writeFile(path, content, 'utf8');
await this.fsDriver().writeFile(path, content, "utf8");
} catch (error) {
throw this.fsErrorToJsError_(error, path);
}
@@ -200,7 +199,7 @@ class FileApiDriverLocal {
}
// let lastError = null;
// for (let i = 0; i < 5; i++) {
// try {
// let output = await fs.move(oldPath, newPath, { overwrite: true });
@@ -221,14 +220,13 @@ class FileApiDriverLocal {
}
format() {
throw new Error('Not supported');
throw new Error("Not supported");
}
async clearRoot(baseDir) {
await this.fsDriver().remove(baseDir);
await this.fsDriver().mkdir(baseDir);
}
}
module.exports = { FileApiDriverLocal };
module.exports = { FileApiDriverLocal };