The downloaded enclosures are not cleaned up once mapped, at which point they are duplicated. Patch adds a delete line after mapping.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

ekes’s picture

Status: Active » Needs review
alex_b’s picture

Status: Needs review » Needs work

Great catch.

Reading up on the mapper and the enclosure I see that the temporary file is not only not removed, but it is downloaded, then *copied*, then not removed.

But reading field_file_save_file() I assume there is no way to avoid copying: field_file_save_file() assumes a local filepath as input that it will copy into its final place. What's more is that not using field_file_save_file() would require significant code duplication and dangerous assumptions about its internal functionality.

Otherwise, that patch is looking good. Need to apply and run tests.

alex_b’s picture

Status: Needs work » Needs review

Sorry, NR of course.

alex_b’s picture

The problem with deleting the file is that right after filemapper there could be another API user calling getFile() and getFile() would return a path to a file that does not exist anymore.

Please review this approach: it deletes temporary files on __destruct().

ekes’s picture

Applied and working as expected here.

alex_b’s picture

Status: Needs review » Reviewed & tested by the community

RTBC?

alex_b’s picture

Title: Enclosures temporary file not deleted » Delete temporary enclosures file
alex_b’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

alex_b’s picture

This patch does not interact well with #755556: Support saving local files in filefields. We will need to remove it at least as a temporary measure. See #919172: Fix enclosure source files deleted.