nextcloud / files_antivirus

👾 Antivirus app for Nextcloud Files
https://apps.nextcloud.com/apps/files_antivirus
GNU Affero General Public License v3.0
86 stars 36 forks source link

Housekeeping of files which are deleted or no longer exist #158

Open johncuthbertuk opened 4 years ago

johncuthbertuk commented 4 years ago

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

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 commented 3 years ago

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!

antonfischl1980 commented 2 years ago

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:

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.