clean gebuggfiggsert

This commit is contained in:
Flummi 2016-09-03 12:50:53 +02:00
parent efc9444589
commit a2d46e9d3d

View File

@ -11,31 +11,26 @@ module.exports = (bot, trigger, lib) => {
var dir_t = fs.readdirSync('./t/'); // Thumbnails
var items_id = [];
var items_dest = [];
var failed_ids = [];
var failed_dests = [];
lib.sql.query("select `id`, `dest` from `f0ck`.`items`", (err, rows, fields) => {
rows.forEach((e,i,a) => {
items_id.push(e.id);
items_dest.push(e.dest.replace('./b/', ''));
items_id.push(e.id+'.png');
items_dest.push(e.dest);
});
dir_b.forEach((e,i,a) => {
if(!(e in items_dest)) {
if( items_dest.indexOf('./b/'+e) === -1 ) {
failed_dests.push(e);
//fs.unlink('./b/'+e);
fs.unlink('./b/'+e);
}
});
dir_t.forEach((e,i,a) => {
if(!(e.replace('.png', '') in items_id)) {
if( items_id.indexOf(e) === -1 ) {
failed_ids.push(e);
//fs.unlink('./t/'+e);
fs.unlink('./t/'+e);
}
});
e.reply('unused thumbnails: ' + failed_ids.length + ' ; unused dests: ' + failed_dests.length);
//console.log(failed_dests);
}).on('error', (err) => {
e.reply(err);
});