Fix for removing sprites
This commit is contained in:
parent
0f595d13f3
commit
7e71ac3c09
@ -20,26 +20,26 @@ export default function (socket: TSocket, io: Server) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
// get root path
|
||||||
|
const public_folder = path.join(process.cwd(), 'public', 'sprites')
|
||||||
|
|
||||||
|
// remove the sprite folder from the disk
|
||||||
|
const finalFilePath = path.join(public_folder, data.id)
|
||||||
|
|
||||||
|
// check if the folder exists
|
||||||
|
if (fs.existsSync(finalFilePath)) {
|
||||||
|
// then remove
|
||||||
|
fs.rmdirSync(finalFilePath)
|
||||||
|
}
|
||||||
|
|
||||||
await prisma.sprite.delete({
|
await prisma.sprite.delete({
|
||||||
where: {
|
where: {
|
||||||
id: data.id
|
id: data.id
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
// get root path
|
callback(true)
|
||||||
const public_folder = path.join(process.cwd(), 'public', 'sprites')
|
|
||||||
|
|
||||||
// remove the tile from the disk
|
|
||||||
const finalFilePath = path.join(public_folder, data.id + '.png')
|
|
||||||
fs.unlink(finalFilePath, (err) => {
|
|
||||||
if (err) {
|
|
||||||
console.log(err)
|
|
||||||
callback(false)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
callback(true)
|
|
||||||
})
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log(e)
|
console.log(e)
|
||||||
callback(false)
|
callback(false)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user