aboutsummaryrefslogtreecommitdiffstats
path: root/cmd_linux.go
diff options
context:
space:
mode:
authorBernhard Guillon <Bernhard.Guillon@begu.org>2026-07-07 23:17:20 +0200
committerBernhard Guillon <Bernhard.Guillon@begu.org>2026-07-07 23:17:20 +0200
commita62e42b9be8402301631c9043f640eb7f43eff29 (patch)
treed85b47ba88a15d9aa7a109c1cd6426ba9faee4f5 /cmd_linux.go
parent2850cd0c3156cdeb42594664cc087641fe740236 (diff)
downloadsourcewatch-main.tar.gz
sourcewatch-main.zip
Add FNV-1a content hash to detect same-size changesHEADmain
Diffstat (limited to 'cmd_linux.go')
-rw-r--r--cmd_linux.go12
1 files changed, 10 insertions, 2 deletions
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