Regarding the unfortunately named: oc_filecache table that is actually an index. From some testing it appears that the mtime column contains the timestamp of the last time a file was modified or the time a folder was added to NextCloud or the time a file was last added to, or updated in, that folder. Is this the intended functionality?
I don’t understand what is the purpose of the storage_mtime column? It seems to mostly be the same as the mtime column.
From testing I found these two confusing situations with adding folders to NextCloud:
- When I use rsync to add a folder with files to NextCloud and then run occ files:scan in this case storage_mtime contains the folders actual OS level modified time but mtime is the time the folder was added to NextCloud.
- When I drag and drop a folder with files in to the NextCloud WebUI both mtime and storage_mtime of the folder are the date the folder was added to NextCloud. Whereas the files in that folder maintain their original OS level modified timestamps so for files mtime and storage_mtime are the same.
Is that intended behaviour or is that a bug? Any explanation gratefully appreciated!
I didn’t see a design document so far (which would have been handy for troubleshooting) so the only source of truth would be the code.
In general having two columns in the DB is definitely nothing which happens without intention. A good reason I could imagine is track glitches between NC database and storage… another intention could be a situation when you e.g. share, comment, un/delete the file etc and you want to keep storage attributes untouched but track this “update” inside application.
Thanks for that. But regarding how Nextcloud handles timestamps… when you add a folder with files to NextCloud. For the Web-UI it keeps the OS-level modified timestamp of a file but gives a fresh timestamp to a folder.
I guess if you think of NextCloud as your on-line File Manager then that behavior makes sense. It makes sense to see when you created that folder in NextCloud.
So maybe I’m crossing purposes. Because in my case I am trying to upgrade my NextCloud instance from a pretty old version to the latest. So I have installed the latest version and now want to add the files and folders from my OLD NextCloud into the NEW one but preserve the timestamps of the files and folders from the OLD one.
I found I have no choice but to go under the hood and run a bunch of mysql updates like:
update oc_filecache set mtime = 1507678688 where fileid = 2822;
And maybe I could save myself time by just doing something like
update oc_filecache set mtime = storage_mtime;
… because the storage_mtime that folders have AFTER they are added from my old NC to the new NC are the timestamps those folders had in the old NC. Or such is my impression from initial playing around.
I think in general it should be more configurable how NextCloud handles and displays file and folder timestamps.