Num_files value in system api?


I am wondering how the number of files on nextcloud instance is calculated ? We can get this value through UI (Settings > System) or through the OCS API with this endpoint : ocs/v2.php/apps/serverinfo/api/v1/info

I came across this topic but it hasn’t been answered so I am opening a new one.

I make the same observation as in this comment where I know fewer files are added than the difference shown with the API.

I don’t think it’s a bug but I would like very much to understand this metric. It could be the previews generation, trashbin, versions, etc. Does anyone know about it?

You should be able to find out more in the app’s code at GitHub - nextcloud/serverinfo: 📊 A monitoring app which creates a server info dashboard for admins

Thank you for referring me the right repo, it was not very clear to me where the different APIs were defined.

This metric is calculated in this function. It is based on the oc_filecache table and sums all the entries per storage (from oc_storages).

I was not able to find relevant information about the way oc_filecache is built but for my account (= my storage) I found in addition to the regular files :

  • files_trashbin/...
  • files_version/...
  • onlyoffice/... (cache files I guess)
  • files_encryption/... (which I do not use, I don’t know why they exist)
  • files_external/... (only rootcerts.crt)

To sum up, oc_filecache seems to be a tree where we have (depending on the activated apps) :

├── cache
├── files
│   └── foo.pdf
├── files_encryption
├── files_external
├── files_trashbin
├── files_versions
├── onlyoffice
└── uploads

and every node counts (even root).