The problem arises when the visitor presses STOP, REFRESH, or BACK or simply closes the browser during file uploads to my Node.js server. There will be some garbage files left in the server.
To deal with this problem, I tried to save the uploaded files to a temporary directory first and delete the files the next time the visitor uploads something again. However, apparently Node.js locks the file being uploaded last time, thus preventing it from being deleted.
The lock on the file will be released when I stop the Node.js server, when it will be deleted finally.
How can I delete the garbage files without restarting the server? I am using the busboy package.