1
0
forked from noxious/server

Fix for removing sprites

This commit is contained in:
Dennis Postma 2024-07-26 19:03:10 +02:00
parent 0f595d13f3
commit 7e71ac3c09

View File

@ -20,26 +20,26 @@ export default function (socket: TSocket, io: Server) {
}
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({
where: {
id: data.id
}
})
// get root path
const public_folder = path.join(process.cwd(), 'public', 'sprites')
callback(true)
// 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) {
console.log(e)
callback(false)