1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-06-12 22:57:38 +02:00

All: Handling of impossible-to-sync items (such as when they are over the size limit of the cloud provider)

This commit is contained in:
Laurent Cozic
2017-12-04 23:38:09 +00:00
parent f6633e23f5
commit 4abe5d07c4
7 changed files with 129 additions and 28 deletions

View File

@ -123,15 +123,27 @@ class FileApiDriverOneDrive {
return this.makeItem_(item);
}
put(path, content, options = null) {
async put(path, content, options = null) {
if (!options) options = {};
if (options.source == 'file') {
return this.api_.exec('PUT', this.makePath_(path) + ':/content', null, null, options);
} else {
options.headers = { 'Content-Type': 'text/plain' };
return this.api_.exec('PUT', this.makePath_(path) + ':/content', null, content, options);
let response = null;
try {
if (options.source == 'file') {
response = await this.api_.exec('PUT', this.makePath_(path) + ':/content', null, null, options);
} else {
options.headers = { 'Content-Type': 'text/plain' };
response = await this.api_.exec('PUT', this.makePath_(path) + ':/content', null, content, options);
}
} catch (error) {
if (error && error.code === 'BadRequest' && error.message === 'Maximum request length exceeded.') {
error.code = 'cannotSync';
error.message = 'Resource exceeds OneDrive max file size (4MB)';
}
throw error;
}
return response;
}
delete(path) {