clj-commons / aleph

Asynchronous streaming communication for Clojure - web server, web client, and raw TCP/UDP
http://aleph.io
MIT License
2.54k stars 241 forks source link

multipart: manual cleanup to handle temporary files #656

Closed arnaudgeiser closed 1 year ago

arnaudgeiser commented 1 year ago

Description

This is a followup PR for #596 (which has been closed in favor of this) to propose a less risky and a backwards compatible approach for multipart requests.

Using temporary files storage is broken with the current release all resources on stream close mechanism. Fixing it is barely feasible without introducing a breaking change. Still, the current mechanism is really convenient: you consume the stream and you are done! It's working perfectly fine as long as you keep all your data on memory. => Let's keep it that way.

I propose here to introduce a manual-cleanup? flag (a better name can be proposed) which will return a vector composed of a manifold.stream and a cleanup function which can be called after the stream has been consumed.

This PR doesn't aim at bringing a file granularity clean up function (which I think is not necessary) as proposed by #596.

And there is also a cljdoc article attached to this PR : https://github.com/clj-commons/aleph/compare/multipart-requests?expand=1#diff-45f6713a5206dde4c1c69d8ddc5242e5ed09e8256ecec0ab80ff911bb8e967c3R1-R82

Closes : #567

arnaudgeiser commented 1 year ago

I had to rebase on master (and handle merge conflicts), but your comments have been addressed. I also bumped to Clojure 1.11 to have access to parse-uuid.

arnaudgeiser commented 1 year ago

Final rebase and merge.