mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-21 07:56:16 -04:00
node8: get rid of node < 0.7 compatibility when deleting files.
- path.exists() is no longer part of nodejs - fs.exists() is deprecated (as of nodejs >= 8) - checking a file for existence before using it is open to raca condition. It is preferable to go ahead and use the file, and eventually handle the error - we can afford two simple synchronous fs operations here
This commit is contained in:
parent
6d36bb2c53
commit
59a6f2e9b8
1 changed files with 13 additions and 10 deletions
|
@ -292,16 +292,19 @@ exports.doImport = function(req, res, padId)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//for node < 0.7 compatible
|
try {
|
||||||
var fileExists = fs.exists || path.exists;
|
fs.unlinkSync(srcFile);
|
||||||
async.parallel([
|
} catch (e) {
|
||||||
function(callback){
|
console.log(e);
|
||||||
fileExists (srcFile, function(exist) { (exist)? fs.unlink(srcFile, callback): callback(); });
|
}
|
||||||
},
|
|
||||||
function(callback){
|
try {
|
||||||
fileExists (destFile, function(exist) { (exist)? fs.unlink(destFile, callback): callback(); });
|
fs.unlinkSync(destFile);
|
||||||
}
|
} catch (e) {
|
||||||
], callback);
|
console.log(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
callback();
|
||||||
}
|
}
|
||||||
], function(err) {
|
], function(err) {
|
||||||
var status = "ok";
|
var status = "ok";
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue