mbi / django-simple-captcha

Django Simple Captcha is an extremely simple, yet highly customizable Django application to add captcha images to any Django form.
http://django-simple-captcha.readthedocs.io/en/latest/
MIT License
1.38k stars 322 forks source link

Remove leftover audio tmpfiles #224

Closed A-dead-pixel closed 10 months ago

A-dead-pixel commented 1 year ago

When generating the audio form of a captha, the resulting audio files are never deleted, thus slowly (?) filling up the tmpdir. They aren't cached or reused either. This PR fixes that by removing the file after the response gets a file descriptor for it.

Closes #225.

dawidratynski commented 10 months ago

This solution will not work on Windows, as os.remove raises an error when removing an open file. Added a PR that should work on both Unix and Windows (#226)

mbi commented 10 months ago

Thank you @dawidratynski and @A-dead-pixel for your PRs!