Commit graph

66 commits

Author SHA1 Message Date
Bart Schuurmans ffee29d8e2 Fix resource leaks
Rewrite places where files (or other resources) are opened but not closed to "with" blocks, which
automatically call close() at the end of the scope.

Also simplify some tests where images need to be saved to a model field: an opened file can be
passed directly to FileField.save().
2024-03-29 20:14:10 +01:00
Bart Schuurmans f423834bd0 Catch the correct exception type from Pillow 2024-03-19 12:42:52 +01:00
Wesley Aptekar-Cassels 3e78e398c0 Switch from priority queues to function-based queues
Fixes: #2907
2023-07-20 12:25:30 -04:00
Wesley Aptekar-Cassels 1048638e30 Stop ignoring task results
This is essentially a revert of 9cbff312a. The commit was at the advice
of the Celery docs for optimization, but I've since decided that the
downsides in terms of making things harder to debug (it makes Flower
nearly useless, for instance) are bigger than the upsides in performance
gain (which seem extremely small in practice, given how long our tasks
take, and the number of tasks we have).
2023-04-07 21:51:44 -04:00
Wesley Aptekar-Cassels 9cbff312a5 Ignore Celery task results
Since we don't use the results of our Celery tasks (all of them return
None implicitly), it's prudent to set the ignore_result flag, for a
potential performance improvement. See the Celery docs for details [1].

We could do this with the global CELERY_IGNORE_RESULT setting, but it
offers more flexibility if we want to use task results in the future to
set it on a per-task basis.

[1]: https://docs.celeryq.dev/en/stable/userguide/tasks.html#ignore-results-you-don-t-want
2023-03-08 02:12:13 -05:00
Joachim f0dc146005 Merge branch 'main' into disable-remote-users-preview-images 2022-12-19 22:32:30 +01:00
Joachim c5eb27a7c5 Lint 2022-12-17 20:27:39 +01:00
Joachim 26f8710c6f Black 2022-12-17 19:52:58 +01:00
Joachim bf82b4cd35 Replace Font.getsize_multiline with Draw.multiline_textbbox 2022-12-17 19:52:52 +01:00
Joachim 003d1425f9 Fix comments 2022-12-17 19:32:10 +01:00
Joachim 684e84f5c3 Remove deprecated Font.getsize()
https://pillow.readthedocs.io/en/stable/deprecations.html#font-size-and-offset-methods
2022-12-17 19:24:07 +01:00
Joachim 86c810ee37 Change ANTIALIAS to Resampling.LANCZOS 2022-12-17 18:44:17 +01:00
Joachim 75ea2cdbb4 Fix generate_user_preview_image_task comment wording 2022-12-17 17:34:49 +01:00
Joachim 09c095cfec Add remove_remote_user_preview_images command 2022-12-17 17:34:27 +01:00
Joachim 8c34b23c35 Disable preview images generation for remote users 2022-12-17 11:39:10 +01:00
André Jaenisch 530d7de309
Use variable instead of string
Signed-off-by: André Jaenisch <andre.jaenisch@posteo.de>
2022-11-13 16:59:05 +01:00
Joel Bradshaw 0c53f4e003 Fix linting and formatting 2022-01-25 01:09:27 -08:00
Joel Bradshaw 9e6390662b Download fonts at app startup instead
We can't bake the font into the Docker image as such, because we mount
the volumes which blows away anything we have in the app tree
beforehand.

We could stash it somewhere in the image and then copy it from there on
app startup or something, but at that point we might as well just
download it as part of the app startup.
2022-01-25 00:53:01 -08:00
Joachim 766a0cc652 Fix tests 2022-01-24 23:16:15 -08:00
Joachim 6f5115c716 Use Source Han Sans for preview images generation 2022-01-24 23:16:15 -08:00
Joachim 5b690532fa Add an AttributeError exception for CI tests 2021-12-04 19:59:45 +01:00
Joachim 5e9e7db935 Fix preview image text wrap length
Closes #1634
2021-12-04 19:08:55 +01:00
Joachim ad6aaa6bc8 Update preview_images.py 2021-11-20 17:15:58 +01:00
Joachim f26a41bd10 Prevent empty file name 2021-11-20 17:10:29 +01:00
Joachim d74df047c5 Clean up file before saving 2021-11-20 16:59:05 +01:00
Joachim 40264e372d Update preview_images.py 2021-11-20 16:26:02 +01:00
Joachim 37508d2583 Update preview_images.py 2021-11-20 16:23:50 +01:00
Mouse Reeve 90c74f00c9 Fixes missing f format in preview image string
plus a unit test for it
2021-09-20 17:40:59 -07:00
Mouse Reeve ea303fb285 Updating string format synatx part 3 2021-09-20 16:45:26 -07:00
Mouse Reeve 08f6a97653 Python formatting 2021-09-18 11:33:43 -07:00
Mouse Reeve 377a4e1ef1 Updating string format syntax part 1 2021-09-17 21:39:18 -07:00
Mouse Reeve aa91361fe4 Fixes celery kwarg for queue 2021-09-07 17:09:44 -07:00
Mouse Reeve de3f18655c Set priorities on tasks 2021-09-07 16:33:43 -07:00
Mouse Reeve 2b6423792c Use update_fields when saving preview images 2021-08-03 11:47:52 -07:00
Joachim 2fbbf522ce Update preview_images.py 2021-06-19 17:46:18 +02:00
Joachim bcb6e1c40a Fix storage media removal 2021-06-19 17:10:25 +02:00
Mouse Reeve 8e7c43baa7 Fixes preview tests 2021-06-18 15:58:21 -07:00
Mouse Reeve 59938e2d46 Linter fixes for models 2021-06-18 15:24:10 -07:00
Mouse Reeve d8d6f57373 Linting fixes for preview image code 2021-06-18 15:08:36 -07:00
Joachim cd7c0ccaea Enable env on GitHub Actions 2021-05-29 15:51:56 +02:00
Joachim 00b09cd07d Try with logging 2021-05-29 14:43:06 +02:00
Joachim fbb262fe88 Try logging output 2021-05-29 13:44:43 +02:00
Joachim cc0881b11c Try another way 2021-05-29 12:33:04 +02:00
Joachim 022182e114 See if the image is saved in DB in the Github Actions test environment 2021-05-29 11:33:37 +02:00
Joachim 0f80456a08 Save as JPG 2021-05-28 23:42:04 +02:00
Joachim 0e28b79089 third time's the charm 2021-05-28 22:10:57 +02:00
Joachim 71bc35224b no, this will work 2021-05-28 22:00:26 +02:00
Joachim 8755b92c2e Fix GitHub FileNotFoundError 2021-05-28 21:40:20 +02:00
Joachim ec159ebcb0 Test generating preview images 2021-05-28 21:24:45 +02:00
Joachim 08cebd7051 Lint 2021-05-28 17:26:43 +02:00