You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-06-15 23:00:36 +02:00
Applied prettier to code base
This commit is contained in:
@ -1,9 +1,8 @@
|
||||
const { time } = require('lib/time-utils.js');
|
||||
const fs = require('fs-extra');
|
||||
const { basicDelta } = require('lib/file-api');
|
||||
const { time } = require("lib/time-utils.js");
|
||||
const fs = require("fs-extra");
|
||||
const { basicDelta } = require("lib/file-api");
|
||||
|
||||
class FileApiDriverMemory {
|
||||
|
||||
constructor() {
|
||||
this.items_ = [];
|
||||
this.deletedItems_ = [];
|
||||
@ -11,14 +10,14 @@ class FileApiDriverMemory {
|
||||
|
||||
encodeContent_(content) {
|
||||
if (content instanceof Buffer) {
|
||||
return content.toString('base64');
|
||||
return content.toString("base64");
|
||||
} else {
|
||||
return Buffer.from(content).toString('base64');
|
||||
return Buffer.from(content).toString("base64");
|
||||
}
|
||||
}
|
||||
|
||||
decodeContent_(content) {
|
||||
return Buffer.from(content, 'base64').toString('utf-8');
|
||||
return Buffer.from(content, "base64").toString("utf-8");
|
||||
}
|
||||
|
||||
itemIndexByPath(path) {
|
||||
@ -40,7 +39,7 @@ class FileApiDriverMemory {
|
||||
isDir: isDir,
|
||||
updated_time: now, // In milliseconds!!
|
||||
// created_time: now, // In milliseconds!!
|
||||
content: '',
|
||||
content: "",
|
||||
};
|
||||
}
|
||||
|
||||
@ -51,7 +50,7 @@ class FileApiDriverMemory {
|
||||
|
||||
async setTimestamp(path, timestampMs) {
|
||||
let item = this.itemByPath(path);
|
||||
if (!item) return Promise.reject(new Error('File not found: ' + path));
|
||||
if (!item) return Promise.reject(new Error("File not found: " + path));
|
||||
item.updated_time = timestampMs;
|
||||
}
|
||||
|
||||
@ -61,9 +60,9 @@ class FileApiDriverMemory {
|
||||
for (let i = 0; i < this.items_.length; i++) {
|
||||
let item = this.items_[i];
|
||||
if (item.path == path) continue;
|
||||
if (item.path.indexOf(path + '/') === 0) {
|
||||
if (item.path.indexOf(path + "/") === 0) {
|
||||
let s = item.path.substr(path.length + 1);
|
||||
if (s.split('/').length === 1) {
|
||||
if (s.split("/").length === 1) {
|
||||
let it = Object.assign({}, item);
|
||||
it.path = it.path.substr(path.length + 1);
|
||||
output.push(it);
|
||||
@ -81,11 +80,11 @@ class FileApiDriverMemory {
|
||||
async get(path, options) {
|
||||
let item = this.itemByPath(path);
|
||||
if (!item) return Promise.resolve(null);
|
||||
if (item.isDir) return Promise.reject(new Error(path + ' is a directory, not a file'));
|
||||
if (item.isDir) return Promise.reject(new Error(path + " is a directory, not a file"));
|
||||
|
||||
let output = null;
|
||||
if (options.target === 'file') {
|
||||
await fs.writeFile(options.path, Buffer.from(item.content, 'base64'));
|
||||
if (options.target === "file") {
|
||||
await fs.writeFile(options.path, Buffer.from(item.content, "base64"));
|
||||
} else {
|
||||
const content = this.decodeContent_(item.content);
|
||||
output = Promise.resolve(content);
|
||||
@ -103,7 +102,7 @@ class FileApiDriverMemory {
|
||||
async put(path, content, options = null) {
|
||||
if (!options) options = {};
|
||||
|
||||
if (options.source === 'file') content = await fs.readFile(options.path);
|
||||
if (options.source === "file") content = await fs.readFile(options.path);
|
||||
|
||||
let index = this.itemIndexByPath(path);
|
||||
if (index < 0) {
|
||||
@ -129,7 +128,7 @@ class FileApiDriverMemory {
|
||||
|
||||
async move(oldPath, newPath) {
|
||||
let sourceItem = this.itemByPath(oldPath);
|
||||
if (!sourceItem) return Promise.reject(new Error('Path not found: ' + oldPath));
|
||||
if (!sourceItem) return Promise.reject(new Error("Path not found: " + oldPath));
|
||||
this.delete(newPath); // Overwrite if newPath already exists
|
||||
sourceItem.path = newPath;
|
||||
}
|
||||
@ -139,7 +138,7 @@ class FileApiDriverMemory {
|
||||
}
|
||||
|
||||
async delta(path, options = null) {
|
||||
const getStatFn = async (path) => {
|
||||
const getStatFn = async path => {
|
||||
let output = this.items_.slice();
|
||||
for (let i = 0; i < output.length; i++) {
|
||||
const item = Object.assign({}, output[i]);
|
||||
@ -156,7 +155,6 @@ class FileApiDriverMemory {
|
||||
async clearRoot() {
|
||||
this.items_ = [];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = { FileApiDriverMemory };
|
||||
module.exports = { FileApiDriverMemory };
|
||||
|
Reference in New Issue
Block a user