FileRepository:deleteUnrefercedFiles Improvements

Prevent the table from locking and a table scan very slow delete by instead querying for the files to remove and then removing them separately.