Skip to Content
Menu
This question has been flagged
3 Replies
16689 Views

I've started to use Maintenance module and noticed that files in filestore directory are not removed after deleting attachments. Is any simple method to make a cleanup of unused files or I need to write a script which will be doing it?

 I know, that using hash of files instead of real names is useful when the same files are attached many times and therefore is not so easy to delete file directly after removing attachment but I hope a cron script would be very desired.

Odoo v.11


Avatar
Discard
Author Best Answer

Self-answer. I found that Odoo makes such cleanup  automatically (in my instalation twice a day) then described problem does not exist. A few houres later filestore directory was freed from unnecessary files.

Odoo v. 12 not 11 as noticed in previous post.

Avatar
Discard
Best Answer

Just to fill inn what I found out. The job that does this is called

Base: Auto-vacuum internal data

and lives here:


class AutoVacuum(models.AbstractModel):
""" Expose the vacuum method to the cron jobs mechanism. """
_name = 'ir.autovacuum'
_description = 'Automatic Vacuum'
.
.
.
@api.model
def power_on(self, *args, **kwargs):
if not self.env.user._is_admin():
raise AccessDenied()
self.env['ir.attachment']._file_gc()
self._gc_transient_models()
self._gc_user_logs()
return True
Avatar
Discard
Best Answer

Hi

I actually have a interesting case. I currently run v15 on odoo.sh and I'm exporting database to try to import it with filestore to different machine for testing and I get 'virus' warning on some file in the odoo db dump.

I was able to locate the phisical file with it's name from antivirus and tried to search for the file in ir.attachment table using the field "Stored Filename" (technical name of field 'store_fname'). Result is the file name that is physically in database dump is not found in the ir.attachment, but the file is physically in the filestore folder when doing db backup.

This is where it gets interesting... in pararel I'm tring to migrate to v17 and have my staging running with v17 version with the same database backup, and there I can find the file in ir.attachment based on it's "Stored Filename".

I want to remove the file from v15 to continue migration, but I cannot locate it.

any ideas?

Avatar
Discard
Related Posts Replies Views Activity
0
Jan 21
7340
1
Dec 17
8011
1
Feb 25
865
5
Oct 24
9992
0
Jul 24
691