From a62e42b9be8402301631c9043f640eb7f43eff29 Mon Sep 17 00:00:00 2001 From: Bernhard Guillon Date: Tue, 7 Jul 2026 23:17:20 +0200 Subject: Add FNV-1a content hash to detect same-size changes --- cmd_linux.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'cmd_linux.go') diff --git a/cmd_linux.go b/cmd_linux.go index 305b7d1..70ee2fb 100644 --- a/cmd_linux.go +++ b/cmd_linux.go @@ -194,13 +194,15 @@ func syncFromManifest(remote *Manifest, stack *GitignoreStack) { if localMeta, exists := localManifest.Files[relPath]; exists { if localMeta.Size == remoteMeta.Size && - localMeta.Symlink == remoteMeta.Symlink { + localMeta.Symlink == remoteMeta.Symlink && + (remoteMeta.Hash == 0 || localMeta.Hash == remoteMeta.Hash) { continue } if debugShown < 5 { - logDebug("mismatch %s: size=%d/%d symlink=%q/%q", + logDebug("mismatch %s: size=%d/%d hash=%d/%d symlink=%q/%q", relPath, localMeta.Size, remoteMeta.Size, + localMeta.Hash, remoteMeta.Hash, localMeta.Symlink, remoteMeta.Symlink) debugShown++ } @@ -310,11 +312,17 @@ func scanLocalDirectory(root string) *Manifest { linkTarget, _ = os.Readlink(path) } + var hash uint64 + if !info.IsDir() && linkTarget == "" { + hash = hashFile(path) + } + manifest.Files[relPath] = FileMeta{ Size: info.Size(), Mode: info.Mode(), ModTime: info.ModTime(), Symlink: linkTarget, + Hash: hash, } return nil -- cgit v1.2.3