Housekeeping of files which are deleted or no longer exist
Steps to reproduce
- Add a file through the UI
- sudo runuser -u nginx -- php -f /nextcloud/html/cron.php
- Check
oc_files_antivirustable which should now include the new file - Delete file through the UI
- sudo runuser -u nginx -- php -f /nextcloud/html/cron.php
Additional steps to try and invoke the intended behaviour
- Update
check_timefor the file to be beyond 28 days
Expected behaviour
The oc_files_antivirus table should no longer have an entry for the file
Actual behaviour
The oc_files_antivirus has files which no longer exist and no house keeping performed
Server configuration
Operating system: RHEL 7 Web server:
Database: Postgres 11.6 PHP version: 7.1 Nextcloud version: (see Nextcloud admin page) 0.17.2
Where did you install Nextcloud from: Direct
List of activated apps:
If you have access to your command line run e.g.:
sudo -u www-data php occ app:list
from within your Nextcloud installation folder
Nextcloud configuration:
If you have access to your command line run e.g.:
sudo -u www-data php occ config:list system
from within your Nextcloud installation folder
or
Insert your config.php content here
Make sure to remove all sensitive content such as passwords. (e.g. database password, passwordsalt, secret, smtp password, …)
Client configuration
Browser:
Operating system:
Logs
Nextcloud log (data/owncloud.log)
Insert your Nextcloud log here
Browser log
Insert your browser log here, this could for example include:
a) The javascript console log
b) The network log
c) ...
It's been quite a while since I originally raised the issues but just wondered if anyone had any thoughts on the issues being faced and how house keeping should be approached.
Similarly, not sure if I've missed how house keeping should be working and maybe the issue lies elsewhere?
Appreciate any help - thanks in advance!
Personally, I run a cronjob that does a query like this once in a while:
DELETE oc_files_antivirus.*
FROM oc_files_antivirus
LEFT JOIN oc_filecache ON oc_filecache.fileid=oc_files_antivirus.fileid
WHERE oc_filecache.fileid IS NULL
AND oc_files_antivirus.check_time<UNIX_TIMESTAMP()-(30*24*60*60)
from bottom up:
- look for entries in oc_files_antivirus which are older than rescan time (28 days, so search for entries older than 30 days)
- and where fileid does no longer exist in oc_filecache
maybe someone can implement a query like this in the background job. this query shouldn't be run every time, but maybe something like once every week or month.