mirror of
https://github.com/BobbyWibowo/lolisafe.git
synced 2025-01-19 01:31:34 +00:00
Made deleting files a promise-thingy
This commit is contained in:
parent
cfba738995
commit
6f06bc930b
@ -146,18 +146,12 @@ uploadsController.delete = function(req, res){
|
|||||||
|
|
||||||
db.table('files').where('id', id).then((file) => {
|
db.table('files').where('id', id).then((file) => {
|
||||||
|
|
||||||
fs.stat('./' + config.uploads.folder + '/' + file[0].name, function (err, stats) {
|
uploadsController.deleteFile(file[0].name).then(() => {
|
||||||
|
db.table('files').where('id', id).del().then(() =>{
|
||||||
if (err) { return res.json({ success: false, description: err.toString() }) }
|
return res.json({ success: true })
|
||||||
|
}).catch(function(error) { console.log(error); res.json({success: false, description: 'error'}) })
|
||||||
fs.unlink('./' + config.uploads.folder + '/' + file[0].name, function(err){
|
}).catch((e) => {
|
||||||
if (err) { return res.json({ success: false, description: err.toString() }) }
|
return res.json({ success: false, description: e.toString() })
|
||||||
|
|
||||||
db.table('files').where('id', id).del().then(() =>{
|
|
||||||
return res.json({ success: true })
|
|
||||||
}).catch(function(error) { console.log(error); res.json({success: false, description: 'error'}) })
|
|
||||||
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
|
|
||||||
}).catch(function(error) { console.log(error); res.json({success: false, description: 'error'}) })
|
}).catch(function(error) { console.log(error); res.json({success: false, description: 'error'}) })
|
||||||
|
Loading…
Reference in New Issue
Block a user