Skip to content

Commit

Permalink
removeTorrents: migrate from rimraf to rmdir(recursive)
Browse files Browse the repository at this point in the history
  • Loading branch information
jesec committed Aug 13, 2020
1 parent 47b2053 commit 916f2e5
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
1 change: 1 addition & 0 deletions package-lock.json

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

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@
"react-router-dom": "^5.2.0",
"react-transition-group": "^4.4.1",
"ress": "^3.0.0",
"rimraf": "^3.0.2",
"run-series": "^1.1.6",
"sass-loader": "^9.0.3",
"saxen": "^8.1.2",
Expand Down
14 changes: 9 additions & 5 deletions server/services/clientGatewayService.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const path = require('path');
const rimraf = require('rimraf');
const fs = require('fs');

const BaseService = require('./BaseService');
const clientGatewayServiceEvents = require('../constants/clientGatewayServiceEvents');
Expand Down Expand Up @@ -102,11 +102,15 @@ class ClientGatewayService extends BaseService {
}, []);

filesToDelete.forEach((file) => {
rimraf(file, {disableGlob: true}, (error) => {
if (error) {
console.error(`Error deleting file: ${file}\n${error}`);
try {
if (fs.lstatSync(file).isDirectory()) {
fs.rmdirSync(file, {recursive: true});
} else {
fs.unlinkSync(file);
}
});
} catch (error) {
console.error(`Error deleting file: ${file}\n${error}`);
}
});
}

Expand Down

0 comments on commit 916f2e5

Please sign in to comment.