This module allows you to "lock" files so they cannot be deleted.

File Lock can be used to control two different problems:

  1. Preventing deliberate deletion of files
  2. Preventing accidental deletion of files caused by the behaviour of Drupal's core file field

File Lock is particularly useful when used with a media library setup, for example using the Media module.


  • "Update options" in file overview (for existing files)
    • Lock selected files
    • Unlock selected files
  • Automatic file lock for new files
    • All files
    • by filename pattern
    • by regular expression
  • Selectable by operation:
    • all -> all file_save actions
    • file_insert -> file create actions (new files)
    • file_update -> file update actions (existing files)
  • Integration with Actions, allowing un/locking of files using Views Bulk Update/Admin Views

File Lock acts in the background, there is no UI which shows the files that are locked and which aren't. A workaround is use a view in media browser showing the file_usage.

Supporting organizations: 

Project Information