sio2project / oioioi

GNU General Public License v3.0
162 stars 72 forks source link

Captcha audio recordings clog up as they are never deleted #277

Open DietPawel opened 11 months ago

DietPawel commented 11 months ago

Steps to reproduce:

  1. Install sox and flite to enable audio captcha files
  2. Play some captcha audio files (for example on sign up page)
  3. Finally all the files end up in /tmp directory and are never deleted by oioioi.
dawidratynski commented 10 months ago

The issue seems to be a bug in the django-simple-captcha library. Generated audio files are never being deleted, even after captcha expires.

Opened issue: https://github.com/mbi/django-simple-captcha/issues/225

A-dead-pixel commented 10 months ago

I made a PR there with a trivial fix in October, though it hasn't been merged nor reviewed yet.

dawidratynski commented 9 months ago

The solution in the current PR will not work on Windows as calling os.remove while the file is in use results in error (https://docs.python.org/3/library/os.html#os.remove). Will add a PR using the tempfile library that should work on both Unix and Windows.

dawidratynski commented 9 months ago

Added a PR that should work on both Unix and Windows. https://github.com/mbi/django-simple-captcha/pull/226

DietPawel commented 9 months ago

Wouldn't your approach create and delete this file on every request?

Keep in mind that /tmp can be separate for different workers of uwsgi when running on separated containers.

I think allowing caching and reusing already created files would require using filetracker with TTL for files. I think S3 supports TTL for files, why not migrate to S3 and make our life easier in the future?