mealie-recipes / mealie

Mealie is a self hosted recipe manager and meal planner with a RestAPI backend and a reactive frontend application built in Vue for a pleasant user experience for the whole family. Easily add recipes into your database by providing the url and mealie will automatically import the relevant data or add a family recipe with the UI editor
https://docs.mealie.io
GNU Affero General Public License v3.0
5.67k stars 617 forks source link

fix: Fix file not found error with individual recipe export/download. #3579

Closed nephlm closed 1 month ago

nephlm commented 2 months ago

What type of PR is this?

(REQUIRED)

What this PR does / why we need it:

(REQUIRED)

This PR fixes the issue that was preventing the recipe download and the /api/recipes/{slug}/exports/zip endpoint more generally from working. As described in #3095, it would fail with a file not found. This was caused by the file being deleted before the Response read the file from the filesystem.

Which issue(s) this PR fixes:

(REQUIRED)

Fixes #3095

Special notes for your reviewer:

(fill-in or delete this section)

I created a version of temporary_zip_path that doesn't unlink when the view completes and added background task to the Response to clean up the file that is run after the Response is delivered to the client.

Renamed the original temporary_zip_path to unlinking_temporary_zip_file and updated references to point to the new name. This seemed like clearer naming given the changes.

Testing