How to cleanup broken uploads on kemal

I have worked on uploads through kemal and thanks for this community I had a lot of progress. So thank you very much for all the support.

My new question is: How can I cleanup a broken temporary file?

Example: I am upload a large file using curl in a endpoint made with kemal. I am saving the temporary file to rename it later.

If I press control+c in the middle of the upload it keeps on the public folder a piece of the file.

I cannot simply delete everything in the public folder because there are other uploads running in parallel.

At the same time, after the download is broken, you lost every data on the env.params.files, so I cannot find the temporary name.

Also I cannot get the temporary name until everything is fully uploaded to env.params.files.

Any thoughts?

Thank you

I wonder if this is an issue with Kemal. The Crystal File.tempfile method creates a temporary file, but those are not garbage-collected by Crystal. They’re expected to be cleaned up either manually or by the operating system.

The /tmp directory will get cleaned up by the OS occasionally, but if tempfiles are created in a directory other than the OS’s tempdir, this automatic cleanup won’t happen, so manual cleanup is your only option. IMO, this should be a responsibility of Kemal if it is the one creating the tempfiles outside of the tempdir.

i made the same program using go lang and if I interrupt the upload ti cleans everything up immediately.
I also believe it is a kemal issue.