Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
import js from "@eslint/js";
import globals from "globals";
import mochaPlugin from 'eslint-plugin-mocha'; // https://www.npmjs.com/package/eslint-plugin-mocha
import stylisticJs from '@stylistic/eslint-plugin-js'
import stylisticJs from '@stylistic/eslint-plugin'

export default [
js.configs.recommended, // Recommended config applied to all files
mochaPlugin.configs.flat.recommended, // or `mochaPlugin.configs.flat.all` to enable all
mochaPlugin.configs.recommended, // or `mochaPlugin.configs.all` to enable all
{
"files": ["lib/**/*.js", "examples/**/*.js", "tests/**/*.js"],
"languageOptions": {
Expand Down
33 changes: 20 additions & 13 deletions lib/MTDropbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,14 @@ export default class MTDropbox {
})
.catch(filesListError => {
MUST_LOG_DEBUG && console.log('filesListError', filesListError)
const {status, error} = filesListError;
const {status} = filesListError;
if (status === 409) {
reject(new Error(`Dropbox path '${path}' dont exist`));
return;
}
const errorMessage = `Dropbox list ${path}: [status:${status}] ${error?.error_summary}`;
reject(new Error(errorMessage));
reject(new Error(
`Dropbox list ${path}: ${dropboxErrorResponseToSummary(filesListError)}`
));
});
})
.catch(err => reject(err));
Expand Down Expand Up @@ -59,9 +60,9 @@ export default class MTDropbox {
})
.catch(uploadErr => {
MUST_LOG_DEBUG && console.log('uploadErr', uploadErr)
const {status, error} = uploadErr;
const errorMessage = `Dropbox upload ${dbxFilename}: [status:${status}] ${error?.error_summary}`;
reject(new Error(errorMessage));
reject(new Error(
`Dropbox upload ${dbxFilename}: ${dropboxErrorResponseToSummary(uploadErr)}`
));
});
});
})
Expand All @@ -71,7 +72,7 @@ export default class MTDropbox {

// https://github.com/dropbox/dropbox-sdk-js/blob/main/examples/javascript/node/download.js
mongorestoreDownloadFromDropbox(options) {
return new Promise( (resolve, reject) => {
return new Promise((resolve, reject) => {
const dbxFullFilename = options.dumpFile;
const localPath = options.getDropboxLocalPath();
const fileName = extractFilename(dbxFullFilename);
Expand All @@ -98,9 +99,9 @@ export default class MTDropbox {
})
.catch(downloadErr => {
MUST_LOG_DEBUG && console.log('downloadErr', downloadErr)
const {status, error} = downloadErr;
const errorMessage = `Dropbox download ${dbxFullFilename}: [status:${status}] ${error?.error_summary}`;
reject(new Error(errorMessage));
reject(new Error(
`Dropbox download ${dbxFullFilename}: ${dropboxErrorResponseToSummary(downloadErr)}`
));
});
})
.catch(err => reject(err));
Expand Down Expand Up @@ -138,9 +139,9 @@ export default class MTDropbox {
})
.catch(filesListError => {
MUST_LOG_DEBUG && console.log('filesListError', filesListError)
const {status, error} = filesListError;
const errorMessage = `Dropbox list ${path}: [status:${status}] ${error?.error_summary}`;
reject(new Error(errorMessage));
reject(new Error(
`Dropbox list ${path}: ${dropboxErrorResponseToSummary(filesListError)}`
));
});
})
.catch(err => reject(err));
Expand Down Expand Up @@ -227,4 +228,10 @@ function getDropbox(options) {
.catch(err => reject(err))
});
})
}

function dropboxErrorResponseToSummary(dropboxResponseError) {
const {status, error} = dropboxResponseError
const error_summary = error?.error_summary /* deprecated */ || error;
return `[status:${status}] ${error_summary}`;
}
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,19 +53,19 @@
"dropbox-refresh-token": "^0.0.5"
},
"devDependencies": {
"@eslint/js": "^9.0.0",
"@stylistic/eslint-plugin-js": "^4.4.1",
"@types/node": "^24.5.0",
"@eslint/js": "^9.35.0",
"@stylistic/eslint-plugin": "^5.3.1",
"@types/node": "^24.5.1",
"chai": "^6.0.1",
"chai-string": "^1.5.0",
"eslint": "^9.0.0",
"chai-string": "^1.6.0",
"eslint": "^9.35.0",
"eslint-plugin-eslint-plugin": "^7.0.0",
"eslint-plugin-mocha": "^11.1.0",
"eslint-plugin-node": "^11.1.0",
"globals": "^16.4.0",
"json5": "^2.2.3",
"mocha": "^11.7.2",
"mongoose": "^8.3.2",
"mongoose": "^8.18.1",
"npm-force-resolutions": "^0.0.10",
"nyc": "^17.1.0"
},
Expand Down
70 changes: 43 additions & 27 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.