files_antivirus Can not open for reading Error thrown for every File on the cloud.

Hi,
I recently reinstalled nextcloud after my old server died.
This time opted for an AIO installation and the transfer of the data from the old server worked nicely.

The problem i’m facing now is with the files_antivirus app.

I continually get the error

Can not open for reading. File: 1287 Account: $ACCOUNT Path: /$ACCOUNT/$PATH_TO_FILE

Followed by

OCA\\Files_Antivirus\\BackgroundJob\\BackgroundScanner::processFiles, exception: 

For Privacy reasons the Account and path have been replaced by placeholders.

This error shows up for virtually every file in the entire instance.
I currently get around 3000 errors per day with just this error.

I tried changing the limits of the max readable file size, but this did not seem to change anything, as ClamAV immediately reverted the size back to the max supported size.

I’m now at a total loss how to stop my log being bombarded by this, other than just uninstalling the antivirus, which i would like to avoid.

Thanks for your Help! And now to the configuration and logs.

General Details

  • Nextcloud Server version (e.g., 29.x.x):
    • 30.0.5
  • Operating system and version (e.g., Ubuntu 24.04):
    • Ubuntu 24.04
  • Web server and version (e.g, Apache 2.4.25):
    • Caddy:alpine docker image
  • Reverse proxy and version _(e.g. nginx 1.27.2)
    • Caddy:alpine docker image
  • PHP version (e.g, 8.3):
    • 8.3
  • Is this the first time you’ve seen this error? (Yes / No):
    • yes
  • When did this problem seem to first start?
    • When first resyncing clients
  • Installation method (e.g. AlO, NCP, Bare Metal/Archive, etc.)
    • AIO
  • Are you using CloudfIare, mod_security, or similar? (Yes / No)
    • No

Log entries

{"reqId":"o3zgKr6L9rOOqa7A2oix","level":3,"time":"2025-02-19T07:58:43+00:00","remoteAddr":"","user":"--","app":"files_antivirus","method":"","url":"--","message":"Can not open for reading. File: 1395 Account: $ACOUNT Path: /$ACCOUNT/$PATH_TO_FILE/","userAgent":"--","version":"30.0.5.1","data":{"app":"files_antivirus"},"id":"67b59117b19b4"}
{"reqId":"o3zgKr6L9rOOqa7A2oix","level":3,"time":"2025-02-19T07:58:43+00:00","remoteAddr":"","user":"--","app":"files_antivirus","method":"","url":"--","message":"OCA\\Files_Antivirus\\BackgroundJob\\BackgroundScanner::processFiles, exception: ","userAgent":"--","version":"30.0.5.1","exception":{"Exception":"RuntimeException","Message":"","Code":0,"Trace":[{"file":"/var/www/html/custom_apps/files_antivirus/lib/Item.php","line":78,"function":"getFileHandle","class":"OCA\\Files_Antivirus\\Item","type":"->","args":[]},{"file":"/var/www/html/custom_apps/files_antivirus/lib/Scanner/ScannerBase.php","line":75,"function":"fread","class":"OCA\\Files_Antivirus\\Item","type":"->","args":[]},{"file":"/var/www/html/custom_apps/files_antivirus/lib/BackgroundJob/BackgroundScanner.php","line":297,"function":"scan","class":"OCA\\Files_Antivirus\\Scanner\\ScannerBase","type":"->","args":[{"__class__":"OCA\\Files_Antivirus\\Item"}]},{"file":"/var/www/html/custom_apps/files_antivirus/lib/BackgroundJob/BackgroundScanner.php","line":147,"function":"scanOneFile","class":"OCA\\Files_Antivirus\\BackgroundJob\\BackgroundScanner","type":"->","args":[{"__class__":"OC\\Files\\Node\\File"}]},{"file":"/var/www/html/custom_apps/files_antivirus/lib/BackgroundJob/BackgroundScanner.php","line":100,"function":"processFiles","class":"OCA\\Files_Antivirus\\BackgroundJob\\BackgroundScanner","type":"->","args":[{"__class__":"LimitIterator"}]},{"file":"/var/www/html/custom_apps/files_antivirus/lib/BackgroundJob/BackgroundScanner.php","line":83,"function":"scan","class":"OCA\\Files_Antivirus\\BackgroundJob\\BackgroundScanner","type":"->","args":[100]},{"file":"/var/www/html/lib/public/BackgroundJob/Job.php","line":61,"function":"run","class":"OCA\\Files_Antivirus\\BackgroundJob\\BackgroundScanner","type":"->","args":[null]},{"file":"/var/www/html/lib/public/BackgroundJob/TimedJob.php","line":88,"function":"start","class":"OCP\\BackgroundJob\\Job","type":"->","args":[{"__class__":"OC\\BackgroundJob\\JobList"}]},{"file":"/var/www/html/lib/public/BackgroundJob/TimedJob.php","line":75,"function":"start","class":"OCP\\BackgroundJob\\TimedJob","type":"->","args":[{"__class__":"OC\\BackgroundJob\\JobList"}]},{"file":"/var/www/html/cron.php","line":162,"function":"execute","class":"OCP\\BackgroundJob\\TimedJob","type":"->","args":[{"__class__":"OC\\BackgroundJob\\JobList"}]}],"File":"/var/www/html/custom_apps/files_antivirus/lib/Item.php","Line":197,"message":"OCA\\Files_Antivirus\\BackgroundJob\\BackgroundScanner::processFiles, exception: ","exception":[],"CustomMessage":"OCA\\Files_Antivirus\\BackgroundJob\\BackgroundScanner::processFiles, exception: "},"id":"67b59117b19b1"}

Configuration

Nextcloud


    "system": {
        "one-click-instance": true,
        "one-click-instance.user-limit": 100,
        "memcache.local": "\\OC\\Memcache\\APCu",
        "apps_paths": [
            {
                "path": "\/var\/www\/html\/apps",
                "url": "\/apps",
                "writable": false
            },
            {
                "path": "\/var\/www\/html\/custom_apps",
                "url": "\/custom_apps",
                "writable": true
            }
        ],
        "check_data_directory_permissions": false,
        "memcache.distributed": "\\OC\\Memcache\\Redis",
        "memcache.locking": "\\OC\\Memcache\\Redis",
        "redis": {
            "host": "***REMOVED SENSITIVE VALUE***",
            "password": "***REMOVED SENSITIVE VALUE***",
            "port": 6379
        },
        "overwritehost": "***REMOVED SENSITIVE VALUE***",
        "overwriteprotocol": "https",
        "passwordsalt": "***REMOVED SENSITIVE VALUE***",
        "secret": "***REMOVED SENSITIVE VALUE***",
        "trusted_domains": [
            "localhost",
            "***REMOVED SENSITIVE VALUE***"
        ],
        "datadirectory": "***REMOVED SENSITIVE VALUE***",
        "dbtype": "pgsql",
        "version": "30.0.5.1",
        "overwrite.cli.url": "https:\/\/***REMOVED SENSITIVE VALUE***\/",
        "dbname": "***REMOVED SENSITIVE VALUE***",
        "dbhost": "***REMOVED SENSITIVE VALUE***",
        "dbport": "",
        "dbtableprefix": "oc_",
        "dbuser": "***REMOVED SENSITIVE VALUE***",
        "dbpassword": "***REMOVED SENSITIVE VALUE***",
        "installed": true,
        "instanceid": "***REMOVED SENSITIVE VALUE***",
        "maintenance": false,
        "loglevel": 2,
        "log_type": "file",
        "logfile": "\/var\/www\/html\/data\/nextcloud.log",
        "log_rotate_size": 10485760,
        "log.condition": {
            "apps": [
                "admin_audit"
            ]
        },
        "preview_max_x": 2048,
        "preview_max_y": 2048,
        "jpeg_quality": 60,
        "enabledPreviewProviders": {
            "1": "OC\\Preview\\Image",
            "2": "OC\\Preview\\MarkDown",
            "3": "OC\\Preview\\MP3",
            "4": "OC\\Preview\\TXT",
            "5": "OC\\Preview\\OpenDocument",
            "6": "OC\\Preview\\Movie",
            "7": "OC\\Preview\\Krita",
            "0": "OC\\Preview\\Imaginary",
            "23": "OC\\Preview\\ImaginaryPDF"
        },
        "enable_previews": true,
        "upgrade.disable-web": true,
        "mail_smtpmode": "smtp",
        "trashbin_retention_obligation": "auto, 30",
        "versions_retention_obligation": "auto, 30",
        "activity_expire_days": 30,
        "simpleSignUpLink.shown": false,
        "share_folder": "\/Shared",
        "one-click-instance.link": "https:\/\/nextcloud.com\/all-in-one\/",
        "upgrade.cli-upgrade-link": "https:\/\/github.com\/nextcloud\/all-in-one\/discussions\/2726",
        "updatedirectory": "\/nc-updater",
        "maintenance_window_start": 100,
        "allow_local_remote_servers": true,
        "davstorage.request_timeout": 3600,
        "documentation_url.server_logs": "https:\/\/github.com\/nextcloud\/all-in-one\/discussions\/5425",
        "htaccess.RewriteBase": "\/",
        "dbpersistent": false,
        "auth.bruteforce.protection.enabled": true,
        "ratelimit.protection.enabled": true,
        "files_external_allow_create_new_local": false,
        "trusted_proxies": "***REMOVED SENSITIVE VALUE***",
        "preview_imaginary_url": "***REMOVED SENSITIVE VALUE***",
        "preview_imaginary_key": "***REMOVED SENSITIVE VALUE***",
        "ldapProviderFactory": "OCA\\User_LDAP\\LDAPProviderFactory",
        "app_install_overwrite": [
            "nextcloud-aio"
        ],
        "data-fingerprint": "187a144f700e6975aecef2367d9930f9",
        "mail_from_address": "***REMOVED SENSITIVE VALUE***",
        "mail_sendmailmode": "smtp",
        "mail_domain": "***REMOVED SENSITIVE VALUE***",
        "default_phone_region": "AT",
        "mail_smtphost": "***REMOVED SENSITIVE VALUE***",
        "mail_smtpport": "587",
        "mail_smtpauth": 1,
        "mail_smtpname": "***REMOVED SENSITIVE VALUE***",
        "mail_smtppassword": "***REMOVED SENSITIVE VALUE***",
        "DOMAIN": "***REMOVED SENSITIVE VALUE***"
    }
}

Apps

Enabled:
  - activity: 3.0.0
  - admin_audit: 1.20.0
  - audioplayer: 3.4.1
  - bookmarks: 15.0.5
  - bruteforcesettings: 3.0.0
  - calendar: 5.0.10
  - circles: 30.0.0
  - cloud_federation_api: 1.13.0
  - comments: 1.20.1
  - contacts: 6.1.3
  - contactsinteraction: 1.11.0
  - cookbook: 0.11.2
  - dashboard: 7.10.0
  - dav: 1.31.1
  - deck: 1.14.3
  - encryption: 2.18.0
  - end_to_end_encryption: 1.16.2
  - epubviewer: 1.6.8
  - federatedfilesharing: 1.20.0
  - federation: 1.20.0
  - files: 2.2.0
  - files_antivirus: 5.6.1
  - files_downloadlimit: 3.0.0
  - files_external: 1.22.0
  - files_fulltextsearch: 30.0.0
  - files_pdfviewer: 3.0.0
  - files_reminders: 1.3.0
  - files_sharing: 1.22.0
  - files_trashbin: 1.20.1
  - files_versions: 1.23.0
  - firstrunwizard: 3.0.0
  - fulltextsearch: 30.0.0
  - fulltextsearch_elasticsearch: 30.0.0
  - gpoddersync: 3.12.0
  - logreader: 3.0.0
  - lookup_server_connector: 1.18.0
  - mail: 4.1.2
  - music: 2.1.2
  - nextcloud-aio: 0.7.0
  - nextcloud_announcements: 2.0.0
  - notes: 4.11.0
  - notifications: 3.0.0
  - notify_push: 1.0.0
  - oauth2: 1.18.1
  - password_policy: 2.0.0
  - photos: 3.0.2
  - privacy: 2.0.0
  - provisioning_api: 1.20.0
  - recommendations: 3.0.0
  - related_resources: 1.5.0
  - richdocuments: 8.5.3
  - serverinfo: 2.0.0
  - settings: 1.13.0
  - sharebymail: 1.20.0
  - support: 2.0.0
  - survey_client: 2.0.0
  - systemtags: 1.20.0
  - text: 4.1.0
  - theming: 2.5.0
  - twofactor_backupcodes: 1.19.0
  - twofactor_nextcloud_notification: 4.0.0
  - twofactor_totp: 12.0.0-dev
  - user_ldap: 1.21.0
  - user_migration: 7.0.1
  - user_status: 1.10.0
  - viewer: 3.0.0
  - weather_status: 1.10.0
  - webhook_listeners: 1.1.0-dev
  - whiteboard: 1.0.5
  - workflowengine: 2.12.0
Disabled:
  - app_api: 4.0.5 (installed 4.0.5)
  - onlyoffice: 9.6.0 (installed 9.6.0)
  - spreed: 20.1.4 (installed 20.1.4)
  - suspicious_login: 8.0.0 (installed 8.0.0)
  - tasks: 0.16.1
  - updatenotification: 1.20.0 (installed 1.20.0)

I think I found at least some of the problem by now.
One of my users, has reportet, not being able to open their files in the web interface. This was also true for my files. Only the files which i have synced after the server migration were availible online. This explains why ClamAV could not open the files.

After reading up, I found out I was supposed to run the command occ files:scan $USER. Which i did on my own account.
Now all files, which i have not uploaded after the transition are gone from the Web interface. The physical files on the other hand still remain in my nextcloud data folder on the external harddrive.

How can I force nextcloud to reread the data folder, since I no longer have all files that were on the data folder on my local machine.

Any help recovering the files would be greatly appreciated!