Add war-log removal on delete; Fix deprecation warning on user delete
parent
377fc0acda
commit
410975e14e
|
@ -259,11 +259,13 @@ users.route('/:id')
|
||||||
// check if signature exists and delete compressed and uncompressed file
|
// check if signature exists and delete compressed and uncompressed file
|
||||||
const fileMinified = __dirname + '/../resource/signature/' + req.params.id + '.png';
|
const fileMinified = __dirname + '/../resource/signature/' + req.params.id + '.png';
|
||||||
if (fs.existsSync(fileMinified)) {
|
if (fs.existsSync(fileMinified)) {
|
||||||
fs.unlink(fileMinified);
|
fs.unlink(fileMinified, (err) => {
|
||||||
|
});
|
||||||
}
|
}
|
||||||
const file = __dirname + '/../resource/signature/big/' + req.params.id + '.png';
|
const file = __dirname + '/../resource/signature/big/' + req.params.id + '.png';
|
||||||
if (fs.existsSync(file)) {
|
if (fs.existsSync(file)) {
|
||||||
fs.unlink(file);
|
fs.unlink(file, (err) => {
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// we don't set res.locals.items and thus it will send a 204 (no content) at the end. see last handler user.use(..)
|
// we don't set res.locals.items and thus it will send a 204 (no content) at the end. see last handler user.use(..)
|
||||||
|
|
|
@ -137,11 +137,26 @@ wars.route('/:id')
|
||||||
return next(err);
|
return next(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: add removal of resource files
|
// delete players having this war ID as foreign key
|
||||||
|
|
||||||
// delete players with this war ID as foreign key
|
|
||||||
PlayerModel.find({warId: item._id}).remove().exec();
|
PlayerModel.find({warId: item._id}).remove().exec();
|
||||||
|
|
||||||
|
// check if logfiles exist and delete from fs
|
||||||
|
const warDir = __dirname + '/../resource/logs/' + req.params.id;
|
||||||
|
|
||||||
|
if (fs.existsSync(warDir)) {
|
||||||
|
const cleanLog = warDir + '/clean.log';
|
||||||
|
if (fs.existsSync(cleanLog)) {
|
||||||
|
fs.unlink(cleanLog, (err) => {
|
||||||
|
});
|
||||||
|
}
|
||||||
|
const sourceLog = warDir + '/war.log';
|
||||||
|
if (fs.existsSync(sourceLog)) {
|
||||||
|
fs.unlink(sourceLog, (err) => {
|
||||||
|
});
|
||||||
|
}
|
||||||
|
fs.rmdir(warDir, (err) => {
|
||||||
|
});
|
||||||
|
}
|
||||||
// we don't set res.locals.items and thus it will send a 204 (no content) at the end. see last handler user.use(..)
|
// we don't set res.locals.items and thus it will send a 204 (no content) at the end. see last handler user.use(..)
|
||||||
res.locals.processed = true;
|
res.locals.processed = true;
|
||||||
next();
|
next();
|
||||||
|
|
Loading…
Reference in New Issue