Why are Directory Modification Times not preserved?

Hi All

In the FAQ: https://github.com/syncthing/syncthing/wiki/FAQ

Is written that the timestamp of directory is not preserved. Why is this so? Is this technical not possible? Is it by design? Is it just not implemented now?

For me the timestamp is a important metadata, I use syncthing to manage my personal archive reaching back till 1998. Losing all directory timestamp is not a good thing. I tried dropbox and Google Drive. Both are not able to preserved timestamp of directory. (Using Isync under Linux)

Thanks for any answer

Martin

It seems it was supported:

But if you do a quick search on the forum:

Beta 3 explains why.

And a commit which does it:

And the issue it points to:

Edit: I guess @calmh has more insight about this, but he’s currently away. The problem was a bug in the stdlib in Go 1.2, but it seems to be solved now, hence you might be able to convince @calmh to accept a pull request adding this functionality back in.

Thank for you detailed information.

How to make an pull request? Shall I change the code back with the change from the commit?

And then make an pull request?

Or is it possible to inverse the commit? (I don’t know git very well)

I will try and then ask @calmh to pull

You cannot just apply the commit, as the logic has changed a lot since then. Basically there are two things I feel you need to do:

  1. Modify the logic here: https://github.com/syncthing/syncthing/blob/master/internal/scanner/walk.go#L224 to start caring about mtimes
  2. Modify the logic somewhere here to update the mtimes: https://github.com/syncthing/syncthing/blob/master/internal/model/puller.go#L477

But please note you need to respect the lenientMtimes setting just like shortcutFile does: https://github.com/syncthing/syncthing/blob/master/internal/model/puller.go#L654

The short answer is that attempting to maintain directory timestamps sucks and is impossible[1] to get to work in a foolproof manner. The bar is high for including it again, as it introduces a fair bit of complexity and probably won’t work as reliably as you’d like anyway…

[1] I think, but feel free to prove me wrong :)

Thanks for this comment. I don’t know if I am able to get It work, not beeing a programming wizard, but there is too a time issue. Also I don’t know Go, just python. So I think about it.

I had the idea to program just a workaround, a local script, which recursively set the timestamp of a folder to the latest timestamp of the containing files.