You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-11-29 22:48:10 +02:00
All: Fixes #632: Handle restricted_content error in Dropbox
This commit is contained in:
@@ -133,6 +133,8 @@ class FileApiDriverDropbox {
|
||||
} catch (error) {
|
||||
if (this.hasErrorCode_(error, 'not_found')) {
|
||||
return null;
|
||||
} else if (this.hasErrorCode_(error, 'restricted_content')) {
|
||||
throw new JoplinError('Cannot download because content is restricted by Dropbox', 'rejectedByTarget');
|
||||
} else {
|
||||
throw error;
|
||||
}
|
||||
|
||||
@@ -266,7 +266,17 @@ class Synchronizer {
|
||||
// could be done using the file timestamp and the potentially unnecessary content loading could be skipped.
|
||||
// OneDrive does not appear to have accurate timestamps as lastModifiedDateTime would occasionally be
|
||||
// a few seconds ahead of what it was set with setTimestamp()
|
||||
try {
|
||||
remoteContent = await this.api().get(path);
|
||||
} 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 (!remoteContent) throw new Error("Got metadata for path but could not fetch content: " + path);
|
||||
remoteContent = await BaseItem.unserialize(remoteContent);
|
||||
|
||||
@@ -485,6 +495,8 @@ class Synchronizer {
|
||||
let local = await BaseItem.loadItemByPath(path);
|
||||
let ItemClass = null;
|
||||
let content = null;
|
||||
|
||||
try {
|
||||
if (!local) {
|
||||
if (remote.isDeleted !== true) {
|
||||
action = "createLocal";
|
||||
@@ -506,6 +518,15 @@ class Synchronizer {
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
if (error.code === 'rejectedByTarget') {
|
||||
this.progressReport_.errors.push(error);
|
||||
this.logger().warn('Rejected by target: ' + path + ': ' + error.message);
|
||||
action = null;
|
||||
} else {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
if (!action) continue;
|
||||
|
||||
@@ -536,7 +557,17 @@ class Synchronizer {
|
||||
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);
|
||||
|
||||
Reference in New Issue
Block a user