'If file not attached to any other record, delete it'

def delete_file(self):

    if (self.file_name and self.content_hash and (not frappe.db.count(u'File', {u'content_hash': self.content_hash, u'name': [u'!=', self.name]}))):
        delete_file_data_content(self)
    elif self.file_url:
        delete_file_data_content(self, only_thumbnail=True)
