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

All: Improved resource side loading

This commit is contained in:
Laurent Cozic
2018-10-08 19:11:53 +01:00
parent dbdd602f50
commit 2f62897fb6
13 changed files with 191 additions and 49 deletions

View File

@ -555,24 +555,28 @@ class Synchronizer {
if (action == "createLocal") options.isNew = true;
if (action == "updateLocal") options.oldItem = local;
if (content.type_ == BaseModel.TYPE_RESOURCE && action == "createLocal") {
let localResourceContentPath = Resource.fullPath(content);
let remoteResourceContentPath = this.resourceDirName_ + "/" + content.id;
try {
await this.api().get(remoteResourceContentPath, { path: localResourceContentPath, target: "file" });
} catch (error) {
if (error.code === 'rejectedByTarget') {
this.progressReport_.errors.push(error);
this.logger().warn('Rejected by target: ' + path + ': ' + error.message);
continue;
} else {
throw error;
}
}
}
// if (content.type_ == BaseModel.TYPE_RESOURCE && action == "createLocal") {
// let localResourceContentPath = Resource.fullPath(content);
// let remoteResourceContentPath = this.resourceDirName_ + "/" + content.id;
// try {
// await this.api().get(remoteResourceContentPath, { path: localResourceContentPath, target: "file" });
// } catch (error) {
// if (error.code === 'rejectedByTarget') {
// this.progressReport_.errors.push(error);
// this.logger().warn('Rejected by target: ' + path + ': ' + error.message);
// continue;
// } else {
// throw error;
// }
// }
// }
await ItemClass.save(content, options);
if (content.type_ == BaseModel.TYPE_RESOURCE && action == "createLocal") {
this.dispatch({ type: "SYNC_CREATED_RESOURCE", id: content.id });
}
if (!hasAutoEnabledEncryption && content.type_ === BaseModel.TYPE_MASTER_KEY && !masterKeysBefore) {
hasAutoEnabledEncryption = true;
this.logger().info("One master key was downloaded and none was previously available: automatically enabling encryption");