From e1fd9c69223de7b9533e420d2c40adb6db7874e3 Mon Sep 17 00:00:00 2001 From: Laurent Cozic Date: Wed, 21 Feb 2018 19:20:33 +0000 Subject: [PATCH] Clean up --- ReactNativeClient/lib/SyncTargetWebDAV.js | 2 +- ReactNativeClient/lib/WebDavApi.js | 2 +- ReactNativeClient/lib/file-api-driver-webdav.js | 9 +-------- ReactNativeClient/lib/registry.js | 8 ++++---- 4 files changed, 7 insertions(+), 14 deletions(-) diff --git a/ReactNativeClient/lib/SyncTargetWebDAV.js b/ReactNativeClient/lib/SyncTargetWebDAV.js index 3237b0b1f..7c67fb5eb 100644 --- a/ReactNativeClient/lib/SyncTargetWebDAV.js +++ b/ReactNativeClient/lib/SyncTargetWebDAV.js @@ -53,7 +53,7 @@ class SyncTargetWebDAV extends BaseSyncTarget { try { const result = await fileApi.stat(''); - if (!result) throw new Error('Could not access WebDAV directory'); + if (!result) throw new Error('WebDAV directory not found: ' + options.path); output.ok = true; } catch (error) { output.errorMessage = error.message; diff --git a/ReactNativeClient/lib/WebDavApi.js b/ReactNativeClient/lib/WebDavApi.js index 6d1ac5e61..ce6dbb3d9 100644 --- a/ReactNativeClient/lib/WebDavApi.js +++ b/ReactNativeClient/lib/WebDavApi.js @@ -307,7 +307,7 @@ class WebDavApi { if (json && json['d:error']) { const code = json['d:error']['s:exception'] ? json['d:error']['s:exception'].join(' ') : response.status; const message = json['d:error']['s:message'] ? json['d:error']['s:message'].join("\n") : 'Unknown error 1'; - throw newError(message + '(Exception ' + code + ')', response.status); + throw newError(message + ' (Exception ' + code + ')', response.status); } throw newError('Unknown error 2', response.status); diff --git a/ReactNativeClient/lib/file-api-driver-webdav.js b/ReactNativeClient/lib/file-api-driver-webdav.js index d2dea8a67..88d104195 100644 --- a/ReactNativeClient/lib/file-api-driver-webdav.js +++ b/ReactNativeClient/lib/file-api-driver-webdav.js @@ -27,7 +27,6 @@ class FileApiDriverWebDav { const result = await this.api().execPropFind(path, 0, [ 'd:getlastmodified', 'd:resourcetype', - // 'd:getcontentlength', // Remove this once PUT call issue is sorted out ]); const resource = this.api().objectFromJson(result, ['d:multistatus', 'd:response', 0]); @@ -56,11 +55,7 @@ class FileApiDriverWebDav { } } - const lastModifiedString = this.api().resourcePropByName(resource, 'string', 'd:getlastmodified'); - - // const sizeDONOTUSE = Number(this.api().stringFromJson(resource, ['d:propstat', 0, 'd:prop', 0, 'd:getcontentlength', 0])); - // if (isNaN(sizeDONOTUSE)) throw new Error('Cannot get content size: ' + JSON.stringify(resource)); - + const lastModifiedString = this.api().resourcePropByName(resource, 'string', 'd:getlastmodified'); // Note: Not all WebDAV servers return a getlastmodified date (eg. Seafile, which doesn't return the // property for folders) so we can only throw an error if it's a file. @@ -70,10 +65,8 @@ class FileApiDriverWebDav { return { path: path, - // created_time: lastModifiedDate.getTime(), updated_time: lastModifiedDate.getTime(), isDir: isDir, - // sizeDONOTUSE: sizeDONOTUSE, // This property is used only for the WebDAV PUT hack (see below) so mark it as such so that it can be removed with the hack later on. }; } diff --git a/ReactNativeClient/lib/registry.js b/ReactNativeClient/lib/registry.js index 17fa0ea62..b2d781337 100644 --- a/ReactNativeClient/lib/registry.js +++ b/ReactNativeClient/lib/registry.js @@ -58,10 +58,10 @@ reg.scheduleSync = async (delay = null) => { reg.logger().info('Scheduling sync operation...'); - // if (Setting.value('env') === 'dev') { - // reg.logger().info('Scheduling sync operation DISABLED!!!'); - // return; - // } + if (Setting.value('env') === 'dev') { + reg.logger().info('Scheduling sync operation DISABLED!!!'); + return; + } const timeoutCallback = async () => { reg.scheduleSyncId_ = null;