Sync Modified Time of Folders



I suspect I already know the answer to this, but I’ll throw it out there anyway, just in case there’s a straightforward answer!

I see the Modified Time of folders is currently not synced across systems. Whilst this might not be an issue in many situations, I just came across a concern from one user where they were convinced the latest version of their document had not synced because the Modified Time was not up to date.

It turns out the document was actually a macOS package - a collection of folders and files masquerading as a single file. As the updated document content was buried deep inside the package (and, indeed, had synced correctly with the correct Modified Time), the Modified Time of the top level of the package was not updated - and consequently did not appear to be updated to the end user.

Is it a conscious decision not to sync the Modified Time of folders, or is it just too complex to do for such a niche requirement?


(Jakob Borg) #2

It’s a conscious decision because it’s somewhat annoying to get right given that temp file operations will change parent directory timestamps etc.

(Tim Smith) #3

This would definitely be a nice-to-have. I see there is an issue for it on GitHub:

But the issue is closed and locked, with the last comment being “This is ready to merge soon”. Was it never implemented? Could the issue be reopened with a summary of the technical difficulties involved?

rsync preserves folder modification times with the -a option.

(Jakob Borg) #4

It was implemented and we had the functionality for a while but there were issues and the functionality was removed. I forget the exact specifics, it was years ago, maybe a little issue tracker archaeology can uncover something.

Rsync does one-direction two pass syncing, where it first transfers then goes through everything once more and resets the timestamps of directories etc. We did the same, sort of.

But we also expect changes from the user in the other direction, which rsync does not. If we have a lot of changes to do in a directory that can take a while (think lots of large files that need to sync; hours potentially). All the while we are doing that we’ll create temp files and stuff, continuously touching the directory modtime. The user may also be doing stuff in the same directory at the same time. What’s the correct modtime on the directory when our sync is done? It depends, becomes generally ill defined, and :man_shrugging:. Also I think the rules for when a directory modtime changes differ between operating systems and file systems.

I suspect I just felt it was more work than it was worth given how few people really care about those timestamps.