avoid vm running out of disk space again
This commit is contained in:
parent
f2a30d7eec
commit
d7efc8f848
|
@ -80,15 +80,22 @@ exports.save = async (ws, req) => {
|
||||||
} else {
|
} else {
|
||||||
const file = fs.readdirSync("videos").find(f => f.includes(id))
|
const file = fs.readdirSync("videos").find(f => f.includes(id))
|
||||||
if (file) {
|
if (file) {
|
||||||
fs.renameSync(`./videos/${file}`, `./videos/${id}.webm`)
|
try {
|
||||||
|
fs.renameSync(`./videos/${file}`, `./videos/${id}.webm`)
|
||||||
|
|
||||||
ws.send('DATA - Uploading file...')
|
ws.send('DATA - Uploading file...')
|
||||||
const videoUrl = await upload.uploadVideo(`./videos/${id}.webm`)
|
const videoUrl = await upload.uploadVideo(`./videos/${id}.webm`)
|
||||||
fs.unlinkSync(`./videos/${id}.webm`)
|
fs.unlinkSync(`./videos/${id}.webm`)
|
||||||
|
|
||||||
await websocket.createDatabaseVideo(id, videoUrl)
|
await websocket.createDatabaseVideo(id, videoUrl)
|
||||||
|
ws.send(`DONE - ${process.env.FRONTEND}/watch?v=${id}`)
|
||||||
ws.send(`DONE - ${process.env.FRONTEND}/watch?v=${id}`)
|
} catch (e) {
|
||||||
|
ws.send('DATA - Server side error while processing video. Please try again.')
|
||||||
|
fs.unlinkSync(`./videos/${id}.webm`)
|
||||||
|
logger.error(e)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
ws.send('DATA - Failed to find file video.')
|
||||||
}
|
}
|
||||||
|
|
||||||
await redis.del(id)
|
await redis.del(id)
|
||||||
|
@ -189,6 +196,7 @@ exports.playlist = async (ws, req) => {
|
||||||
ws.send(`DATA - Created video page for ${video.title}`)
|
ws.send(`DATA - Created video page for ${video.title}`)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
ws.send(`DATA - Failed downloading video ${video.title}. Going to next video`)
|
ws.send(`DATA - Failed downloading video ${video.title}. Going to next video`)
|
||||||
|
fs.unlinkSync(`./videos/${id}.webm`)
|
||||||
logger.error(e)
|
logger.error(e)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -287,6 +295,7 @@ exports.channel = async (ws, req) => {
|
||||||
ws.send(`DATA - Created video page for ${video.title}`)
|
ws.send(`DATA - Created video page for ${video.title}`)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
ws.send(`DATA - Failed downloading video ${video.title}. Going to next video`)
|
ws.send(`DATA - Failed downloading video ${video.title}. Going to next video`)
|
||||||
|
fs.unlinkSync(`./videos/${id}.webm`)
|
||||||
logger.error(e)
|
logger.error(e)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue