Adjusted the indentation and formatting across several files for better readability. Enhanced the file deletion logic to handle cases where a file is found in the database but not in storage, and to delete only from the database when there are multiple references.