0

So this is my code

fs.unlink(`storage/videos/${videoId + path.extname(file.originalname)}`, err => {
   if (err) return console.log(err)
   console.log(`deleted video: ${videoId + path.extname(file.originalname)}`)
})

This thing console logs the deleted video but it won't remove it from folder until I won't do server restart, I used same code for image and It removes image immediately, Idk what's issue with video

eldernyPro
  • 11
  • 2
  • Which OS are you using? – robertklep Jul 04 '22 at 05:35
  • Windows, But what has it to do with my os – eldernyPro Jul 04 '22 at 05:49
  • Windows has different file system semantics than most Unix file systems. If, for instance, the file is still being written, or even just open, it may not want to remove the file entry from the directory (as opposed to on Unix, where it's perfectly fine to remove files that are still "in use"). – robertklep Jul 04 '22 at 05:52
  • what can i do to remove it then – eldernyPro Jul 04 '22 at 06:01
  • Don't think you can. But you should try and find out if it's actually caused by the file still being in use, I could be talking rubbish :) (I don't use Windows so can't recommend any tools) – robertklep Jul 04 '22 at 06:06
  • no worries, I found the solution. I had to stop reading that video file before deleting it :) – eldernyPro Jul 04 '22 at 07:42

0 Answers0