Purge files in the filestore of deleted attachments

Thank you for this warning.

I still think such a feature would be useful : one of my user often update / replace a lot of big files in attachements. The filestore backup archive will be soon ridiculousely huge.

A quick and dirty solution for my case was to add this function in ir.attachment :

@classmethod
def delete(cls, records):
    # [attachment].purge_deleted = True -> delete file
    if config.getboolean('attachment', 'purge_deleted', default=False):
        for record in records:
            if record.file_id is not None:
                path = filestore._filename(record.file_id,config.get('attachment', 'store_prefix', default=None))
                # print(path)
                os.remove(path)
    super(Attachment, cls).delete(records)

There is still room for improvement as it don’t delete empty directories.

It would be nice to implement it for any delete/updated binary field, but I’m not sure yet how to intercept modification/deleting on the Binary object…