In our system we have some files hosted on external storage services and both files and generated pages are cached through a reverse proxy.

To make sure that we don't delete a file which is still referred to by a page cached in the reverse proxy, we need to make delayed deletes of all files.

This is done by introducing a hook in the file_unmanaged_delete() function, which allows other modules to alter the list of functions called when a module requests a file delete. In our case we replace the drupal_unlink with our own function that adds file URI to a queue of files scheduled to be deleted in the future, and we have implemented a cron job to do the actual deletion at a later time.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

esbenvb’s picture

Here's a patch.

IMPORTANT: When porting the patch, remember to supply the correct author information as mentioned here:
http://drupal.org/user/989064

dudycz’s picture

I'm still learning Drupal so forgive me the question but is it not to late to add hook to 7.x?