From 0b1475169f933e6f15f55bc50a663b6aa6339ca9 Mon Sep 17 00:00:00 2001 From: Jakob Borg Date: Tue, 16 Aug 2016 18:22:19 +0000 Subject: [PATCH] lib/model: Correct virtual mtime handling (fixes #3516) We previously set the mtime on the temp file, and then renamed it to the real path. Unfortunately that means we'd save the real timestamp under the under the temp name ".syncthing.foo.tmp" when the actual file that we will look up on the next scan is "foo". This moves the Chtimes later, ensuring that it gets recorded correctly under the right name. GitHub-Pull-Request: https://github.com/syncthing/syncthing/pull/3519 --- lib/model/rwfolder.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/model/rwfolder.go b/lib/model/rwfolder.go index 8b73f886a..5e6ce3612 100644 --- a/lib/model/rwfolder.go +++ b/lib/model/rwfolder.go @@ -1245,9 +1245,6 @@ func (f *rwFolder) performFinish(state *sharedPullerState) error { } } - // Set the correct timestamp on the new file - f.mtimeFS.Chtimes(state.tempName, state.file.ModTime(), state.file.ModTime()) // never fails - if stat, err := f.mtimeFS.Lstat(state.realName); err == nil { // There is an old file or directory already in place. We need to // handle that. @@ -1294,6 +1291,9 @@ func (f *rwFolder) performFinish(state *sharedPullerState) error { return err } + // Set the correct timestamp on the new file + f.mtimeFS.Chtimes(state.realName, state.file.ModTime(), state.file.ModTime()) // never fails + // If it's a symlink, the target of the symlink is inside the file. if state.file.IsSymlink() { content, err := ioutil.ReadFile(state.realName)