From the question What happens if a user uploads an image but doesn't save the node? and its answer, there is a table called file_managed
and for any uploaded file (an image in my case), it sets 0
in status
column, and if the image node is saved, it is set to 1
. During each cron run, all files with 0
status will be removed.
I am using bulk_file_nodes module to upload the images. Unfortunately, this module sets the status 1
for uploaded files and no matter if their node is saved or not.
I need to accomplish what Drupal core does for unsaved nodes of uploaded files. To do so I have to list those files. There are about 30000 images and about 2500 nodes in my website that are uploaded by people and it is growing very fast every day.
The brute force method is to check the entire fid
column of field_data_field_image
table of the database for every file (in fact for every fid
of file_managed
) to see if that file is attached to a node or not, I think it is not a good solution at all.
Is there any way else to handle this?
thanks