You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-06-15 23:00:36 +02:00
First pass at linting lib dir
This commit is contained in:
@ -22,7 +22,7 @@ async function tryAndRepeat(fn, count) {
|
||||
const shimFetchMaxRetryPrevious = shim.fetchMaxRetrySet(0);
|
||||
const defer = () => {
|
||||
shim.fetchMaxRetrySet(shimFetchMaxRetryPrevious);
|
||||
}
|
||||
};
|
||||
|
||||
while (true) {
|
||||
try {
|
||||
@ -37,11 +37,10 @@ async function tryAndRepeat(fn, count) {
|
||||
retryCount++;
|
||||
await time.sleep(1 + retryCount * 3);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class FileApi {
|
||||
|
||||
constructor(baseDir, driver) {
|
||||
this.baseDir_ = baseDir;
|
||||
this.driver_ = driver;
|
||||
@ -165,9 +164,9 @@ class FileApi {
|
||||
|
||||
async put(path, content, options = null) {
|
||||
this.logger().debug('put ' + this.fullPath_(path), options);
|
||||
|
||||
|
||||
if (options && options.source === 'file') {
|
||||
if (!await this.fsDriver().exists(options.path)) throw new JoplinError('File not found: ' + options.path, 'fileNotFound');
|
||||
if (!(await this.fsDriver().exists(options.path))) throw new JoplinError('File not found: ' + options.path, 'fileNotFound');
|
||||
}
|
||||
|
||||
return tryAndRepeat(() => this.driver_.put(this.fullPath_(path), content, options), this.requestRepeatCount());
|
||||
@ -197,7 +196,6 @@ class FileApi {
|
||||
this.logger().debug('delta ' + this.fullPath_(path));
|
||||
return tryAndRepeat(() => this.driver_.delta(this.fullPath_(path), options), this.requestRepeatCount());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function basicDeltaContextFromOptions_(options) {
|
||||
@ -217,7 +215,7 @@ function basicDeltaContextFromOptions_(options) {
|
||||
output.filesAtTimestamp = Array.isArray(options.context.filesAtTimestamp) ? options.context.filesAtTimestamp.slice() : [];
|
||||
output.statsCache = options.context && options.context.statsCache ? options.context.statsCache : null;
|
||||
output.statIdsCache = options.context && options.context.statIdsCache ? options.context.statIdsCache : null;
|
||||
output.deletedItemsProcessed = options.context && ('deletedItemsProcessed' in options.context) ? options.context.deletedItemsProcessed : false;
|
||||
output.deletedItemsProcessed = options.context && 'deletedItemsProcessed' in options.context ? options.context.deletedItemsProcessed : false;
|
||||
|
||||
return output;
|
||||
}
|
||||
@ -246,9 +244,7 @@ async function basicDelta(path, getDirStatFn, options) {
|
||||
newContext.statsCache.sort(function(a, b) {
|
||||
return a.updated_time - b.updated_time;
|
||||
});
|
||||
newContext.statIdsCache = newContext.statsCache
|
||||
.filter(item => BaseItem.isSystemPath(item.path))
|
||||
.map(item => BaseItem.pathToId(item.path));
|
||||
newContext.statIdsCache = newContext.statsCache.filter(item => BaseItem.isSystemPath(item.path)).map(item => BaseItem.pathToId(item.path));
|
||||
newContext.statIdsCache.sort(); // Items must be sorted to use binary search below
|
||||
}
|
||||
|
||||
@ -325,4 +321,4 @@ async function basicDelta(path, getDirStatFn, options) {
|
||||
};
|
||||
}
|
||||
|
||||
module.exports = { FileApi, basicDelta };
|
||||
module.exports = { FileApi, basicDelta };
|
||||
|
Reference in New Issue
Block a user