Question about Antivirus for files App

Hi,

I have configured Antivirus for files with ClamAV daemon over TCP socket that way:

Basically, I installed a Nextcloud instance as docker container on a Home Assistant server and another container with ClamAV.

When I upload an album of photos (for example), these are scanned with ClamAV and after that, they are stored.

So far so good.

The main problem that I have noticed is that each photo that I want to see is scanned with ClamAV once again (that was already scanned when I uploaded), therefore I have to wait an average of 3 seconds to actually see the photo. When I disable the Antivirus for files app, each photo is delivered in average of 1 second.
Also, this happens only first time I see a photo. After that, whenever I see the same photo again, this is delivered as usual in average of 1 second. I suppose this is marked as scanned in database (although this should be marked as scanned in the first place when it is uploaded).

In the documentation I found only how to disable the background scanning. I tried that but nothing changed regarding to my problem.

I didn’t switched the logging level to debug to see what happened. The only thing that I monitored was the statistics of docker containers (docker stats). There I noticed how the CPU usage is rising at ClamAV container each time I see a photo.

In conclusion, why does the same file need to be scanned twice ?
I not sure if this should be the normal way how this app was designed to work.

If not, where am I wrong ?

I think this is related to scanning the created thumb previews.