You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
751 B

const fs = require('fs')
const exists = async file => {
return new Promise(res => {
fs.promises.stat(file).then(() => res(true)).catch(() => res(false))
})
}
module.exports = exports = async (message, di) => {
console.log('[RELEASE]')
const { descriptor } = message.data()
const node_uuid = message.socket.session.file_descriptors?.[descriptor]
if ( node_uuid ) {
delete message.socket.session.file_descriptors[descriptor]
}
const placeholder = message.socket.session.temp_write_files?.[node_uuid]
if ( placeholder && (await exists(placeholder.path)) ) {
await fs.promises.unlink(placeholder.path)
}
message.send_response(
message.fresh()
)
console.log('[/RELEASE]')
}