1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-06-15 23:00:36 +02:00

All: Handle case where resource blob is missing during sync

This commit is contained in:
Laurent Cozic
2018-01-21 17:01:37 +00:00
parent e355f4e49b
commit 86eee376bb
9 changed files with 47 additions and 19 deletions

View File

@ -1,5 +1,7 @@
const { isHidden } = require('lib/path-utils.js');
const { Logger } = require('lib/logger.js');
const { shim } = require('lib/shim');
const JoplinError = require('lib/JoplinError');
class FileApi {
@ -10,6 +12,10 @@ class FileApi {
this.syncTargetId_ = null;
}
fsDriver() {
return shim.fsDriver();
}
driver() {
return this.driver_;
}
@ -83,8 +89,13 @@ class FileApi {
return this.driver_.get(this.fullPath_(path), options);
}
put(path, content, options = null) {
this.logger().debug('put ' + this.fullPath_(path));
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');
}
return this.driver_.put(this.fullPath_(path), content, options);
}