Renaming a file doesn't change the last modification date


I have a development-related question and I wish I am here in the right place.

I’m developing a NextCloud App where events about files should be tracked and used in external systems.
I was wondering that when a file in NextCloud (or ownCloud) is renamed, the value of the last modification date from \OCP\Files\Node->getMTime() does not change.

Is the reason simply because NextCloud is a file system in some way and therefore the last modification date does not change when you rename a file, and only when you change the file’s content? Or there is some other reason for having such behaviour? and will this be changed in the future?

Thank you in advance

It’s not Nextcloud dependent, but usual POSIX behaviour. The mtime changes only, when the contents are modified.

The ctime gets also modified when meta information has changed. We do not expose it however, and I doubt we sync on every change (renaming yes, file permission changes rather not).

…therefore the behaviour for mtime won’t be changed.

P.S.: references

1 Like