Ocfilecache contains 1.5m records - only ~255K files on instance


My ocfilecache table contains 1.5m rows, but I only have 255,069 files in my data dir:

find /mnt/data -type f|wc -l

I have tried using the occ files:cleanup command and it just returns:

0 orphaned file cache entries deleted

Why does occ files:cleanup not remove these entries? From what I can tell, the orphan records in the table belong to users which have been deleted via the web interface. Is occ files:cleanup not deleting the orphaned records because they don’t belong to an existing user?

It seems like already known, but I did not seen any new OCC command for this:

Thanks, I did see that.

Most of the people there are having the issue because of external storage. We don’t use any external storage whatsoever, and we also haven’t ever deleted any files except through nextcloud directly, either using the nextcloud sync client, or the web interface.

We have had, however, tons of problems deleting large directories in the past with the web interface shows errors when deleting folders with thousands of files. Its been better in recent versions but my filecache table has records that were deleted years ago.

Sounds like time-out errors. That the PHP session time out before all files are deleted or moved to trash or versions history.

You can empty the oc_filecache with your favourite mysql editor. Then issue a occ files:scan --all -v to rebuild it.

Also, have you checked it isn’t previews? They can become 10 times more than the actual files.

I think it was just very buggy in earlier versions… Selecting folders with thousands of files and hitting “delete” in the web interface use to come up with “error” after about 5 seconds, way before any php timeouts.

Doesn’t seem to be an issue anymore, maybe its just more stable in later versions or maybe it’s because I’ve been tuning php settings such as memory limits, etc.

If I empty the file cache table, won’t I loose all my share links, of which I have around 400?


I do not believe so, but I am not sure.

At least my shares are listed in table oc_shares.

You can verify yours:

SELECT * FROM `oc_share`

sure you lose the shares, because the newly scanned files got another file_id, so the share is connected to “nothing”