files_antivirus icon indicating copy to clipboard operation
files_antivirus copied to clipboard

Housekeeping of files which are deleted or no longer exist

Open johncuthbertuk opened this issue 5 years ago • 2 comments

Steps to reproduce

  1. Add a file through the UI
  2. sudo runuser -u nginx -- php -f /nextcloud/html/cron.php
  3. Check oc_files_antivirus table which should now include the new file
  4. Delete file through the UI
  5. sudo runuser -u nginx -- php -f /nextcloud/html/cron.php

Additional steps to try and invoke the intended behaviour

  • Update check_time for 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) ...

johncuthbertuk avatar Aug 20 '20 12:08 johncuthbertuk

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!

johncuthbertuk avatar Jan 15 '21 18:01 johncuthbertuk

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.

antonfischl1980 avatar Dec 25 '21 06:12 antonfischl1980