diff options
| author | Bernhard Guillon <Bernhard.Guillon@begu.org> | 2026-07-07 21:40:50 +0200 |
|---|---|---|
| committer | Bernhard Guillon <Bernhard.Guillon@begu.org> | 2026-07-07 21:40:50 +0200 |
| commit | e7bb8c7c595fc9e2a024c2694596750b6a9f6480 (patch) | |
| tree | 559ec42bea0724f84cd902e09ebfc31c67934492 | |
| parent | 17f5736495ea4a219d70fbef696c1b43bac00128 (diff) | |
| download | sourcewatch-e7bb8c7c595fc9e2a024c2694596750b6a9f6480.tar.gz sourcewatch-e7bb8c7c595fc9e2a024c2694596750b6a9f6480.zip | |
Preserve modtime on copy so subsequent syncs don't re-copy everything
| -rw-r--r-- | sync.go | 13 |
1 files changed, 11 insertions, 2 deletions
@@ -141,6 +141,15 @@ func copyFile(src, dst string, mode os.FileMode) error { } defer dstFile.Close() - _, err = io.Copy(dstFile, srcFile) - return err + if _, err = io.Copy(dstFile, srcFile); err != nil { + return err + } + + // Preserve modtime so next sync comparison matches + srcInfo, err := os.Lstat(src) + if err != nil { + return nil // content copied, modtime is non-fatal + } + os.Chtimes(dst, srcInfo.ModTime(), srcInfo.ModTime()) + return nil } |
