@@ -13,7 +13,7 @@ import {
13
13
generateCodeVerifier,
14
14
} from './util';
15
15
import {requestWithTimeout, isArrayBufferView, retryAfterMs} from "./requests";
16
- import {Remote, RemoteBase, RemoteResponse, RemoteSettings} from "./Remote ";
16
+ import {Remote, RemoteBase, RemoteResponse, RemoteSettings} from "./remote ";
17
17
import RemoteStorage from "./remotestorage";
18
18
import Authorize from "./authorize";
19
19
@@ -282,7 +282,6 @@ class Dropbox extends RemoteBase implements Remote {
282
282
* @private
283
283
*/
284
284
_getFolder (path: string) {
285
- const url = FOLDER_URL;
286
285
const revCache = this._revCache;
287
286
288
287
const processResponse = (resp) => {
@@ -334,15 +333,14 @@ class Dropbox extends RemoteBase implements Remote {
334
333
};
335
334
336
335
const loadNext = (cursor) => {
337
- const continueURL = CONTINUE_URL;
338
336
const params = {
339
337
body: { cursor: cursor }
340
338
};
341
339
342
- return this._request('POST', continueURL , params).then(processResponse);
340
+ return this._request('POST', CONTINUE_URL , params).then(processResponse);
343
341
};
344
342
345
- return this._request('POST', url , {
343
+ return this._request('POST', FOLDER_URL , {
346
344
body: {
347
345
path: getDropboxPath(path)
348
346
}
@@ -371,8 +369,6 @@ class Dropbox extends RemoteBase implements Remote {
371
369
*/
372
370
get (path: string, options: { ifNoneMatch?: string } = {}): Promise<RemoteResponse> {
373
371
if (! this.connected) { return Promise.reject("not connected (path: " + path + ")"); }
374
- const url = DOWNLOAD_URL;
375
-
376
372
const savedRev = this._revCache.get(path);
377
373
if (savedRev === null) {
378
374
// file was deleted server side
@@ -408,7 +404,7 @@ class Dropbox extends RemoteBase implements Remote {
408
404
params.headers['If-None-Match'] = options.ifNoneMatch;
409
405
}
410
406
411
- return this._request('GET', url , params).then(resp => {
407
+ return this._request('GET', DOWNLOAD_URL , params).then(resp => {
412
408
const status = resp.status;
413
409
let meta, body, mime, rev;
414
410
if (status !== 200 && status !== 409) {
@@ -592,12 +588,11 @@ class Dropbox extends RemoteBase implements Remote {
592
588
* @private
593
589
*/
594
590
share (path: string): Promise<string> {
595
- const url = CREATE_SHARED_URL;
596
591
const options = {
597
592
body: {path: getDropboxPath(path)}
598
593
};
599
594
600
- return this._request('POST', url , options).then((response) => {
595
+ return this._request('POST', CREATE_SHARED_URL , options).then((response) => {
601
596
if (response.status !== 200 && response.status !== 409) {
602
597
return Promise.reject(new Error('Invalid response status:' + response.status));
603
598
}
@@ -641,9 +636,7 @@ class Dropbox extends RemoteBase implements Remote {
641
636
* @protected
642
637
*/
643
638
info (): Promise<{email: string}> {
644
- const url = ACCOUNT_URL;
645
-
646
- return this._request('POST', url, {}).then(function (response) {
639
+ return this._request('POST', ACCOUNT_URL, {}).then(function (response) {
647
640
let email;
648
641
649
642
try {
@@ -768,13 +761,14 @@ class Dropbox extends RemoteBase implements Remote {
768
761
769
762
/** This should resolve (with no value) on success, and reject on error. */
770
763
const fetch = async (cursor: string) => {
771
- let url = FOLDER_URL ;
764
+ let url;
772
765
let requestBody;
773
766
774
767
if (typeof cursor === 'string') {
775
- url += '/continue' ;
768
+ url = CONTINUE_URL ;
776
769
requestBody = { cursor };
777
770
} else {
771
+ url = FOLDER_URL;
778
772
requestBody = {
779
773
path: PATH_PREFIX,
780
774
recursive: true,
@@ -873,12 +867,11 @@ class Dropbox extends RemoteBase implements Remote {
873
867
* @private
874
868
*/
875
869
_getMetadata (path: string): Promise<Metadata> {
876
- const url = METADATA_URL;
877
870
const requestBody = {
878
871
path: getDropboxPath(path)
879
872
};
880
873
881
- return this._request('POST', url , { body: requestBody }).then((response) => {
874
+ return this._request('POST', METADATA_URL , { body: requestBody }).then((response) => {
882
875
if (response.status !== 200 && response.status !== 409) {
883
876
return Promise.reject(new Error('Invalid response status:' + response.status));
884
877
}
@@ -922,7 +915,6 @@ class Dropbox extends RemoteBase implements Remote {
922
915
* @private
923
916
*/
924
917
_uploadSimple (params: { body: XMLHttpRequestBodyInit; contentType?: string; path: string; ifMatch?: string; }): Promise<RemoteResponse> {
925
- const url = UPLOAD_URL;
926
918
const args = {
927
919
path: getDropboxPath(params.path),
928
920
mode: { '.tag': 'overwrite', update: undefined },
@@ -933,7 +925,7 @@ class Dropbox extends RemoteBase implements Remote {
933
925
args.mode = { '.tag': 'update', update: params.ifMatch };
934
926
}
935
927
936
- return this._request('POST', url , {
928
+ return this._request('POST', UPLOAD_URL , {
937
929
body: params.body,
938
930
headers: {
939
931
'Content-Type': 'application/octet-stream',
@@ -982,10 +974,9 @@ class Dropbox extends RemoteBase implements Remote {
982
974
* @private
983
975
*/
984
976
_deleteSimple (path: string): Promise<RemoteResponse> {
985
- const url = DELETE_URL;
986
977
const requestBody = { path: getDropboxPath(path) };
987
978
988
- return this._request('POST', url , { body: requestBody }).then((response) => {
979
+ return this._request('POST', DELETE_URL , { body: requestBody }).then((response) => {
989
980
if (response.status !== 200 && response.status !== 409) {
990
981
return Promise.resolve({statusCode: response.status});
991
982
}
@@ -1028,15 +1019,14 @@ class Dropbox extends RemoteBase implements Remote {
1028
1019
* @private
1029
1020
*/
1030
1021
async _getSharedLink (path: string): Promise<string> {
1031
- const url = LIST_SHARED_URL;
1032
1022
const options = {
1033
1023
body: {
1034
1024
path: getDropboxPath(path),
1035
1025
direct_only: true
1036
1026
}
1037
1027
};
1038
1028
1039
- return this._request('POST', url , options).then((response) => {
1029
+ return this._request('POST', LIST_SHARED_URL , options).then((response) => {
1040
1030
if (response.status !== 200 && response.status !== 409) {
1041
1031
return Promise.reject(new Error('Invalid response status: ' + response.status));
1042
1032
}
0 commit comments