Add war-log removal on delete; Fix deprecation warning on user delete

pull/1/head
Florian Hartwich 2017-07-15 10:54:35 +02:00
parent 377fc0acda
commit 410975e14e
2 changed files with 22 additions and 5 deletions

View File

@ -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(..)

View File

@ -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();