mirror of https://github.com/perkeep/perkeep.git
camput: ignore atimes
Change-Id: Ia55d6fef6a8e3aa95b6265c958853da7b170e3c4
This commit is contained in:
parent
6b466d0faa
commit
6b7d73d757
|
@ -38,12 +38,20 @@ import (
|
|||
|
||||
type statFingerprint string
|
||||
|
||||
var cleanSysStat func(v interface{}) interface{}
|
||||
|
||||
func fileInfoToFingerprint(fi os.FileInfo) statFingerprint {
|
||||
// We calculate the CRC32 of the underlying system stat structure to get
|
||||
// ctime, owner, group, etc. This is overkill (e.g. we don't care about
|
||||
// the inode or device number probably), but works.
|
||||
sysHash := uint32(0)
|
||||
if sys := fi.Sys(); sys != nil {
|
||||
if clean := cleanSysStat; clean != nil {
|
||||
// TODO: don't clean bad fields, but provide a
|
||||
// portable way to extract all good fields.
|
||||
// This is a Linux+Mac-specific hack for now.
|
||||
sys = clean(sys)
|
||||
}
|
||||
var buf bytes.Buffer
|
||||
fmt.Fprintf(&buf, "%#v", sys)
|
||||
sysHash = crc32.ChecksumIEEE(buf.Bytes())
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
//+build darwin
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"syscall"
|
||||
)
|
||||
|
||||
func init() {
|
||||
cleanSysStat = func(si interface{}) interface{} {
|
||||
st, ok := si.(*syscall.Stat_t)
|
||||
if !ok {
|
||||
return si
|
||||
}
|
||||
st.Atimespec = syscall.Timespec{}
|
||||
return st
|
||||
}
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
//+build linux
|
||||
|
||||
// TODO: move this to somewhere generic in osutil; use it for all
|
||||
// posix-y operation systems? Or rather, don't clean bad fields, but
|
||||
// provide a portable way to extract all good fields.
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"syscall"
|
||||
)
|
||||
|
||||
func init() {
|
||||
cleanSysStat = func(si interface{}) interface{} {
|
||||
st, ok := si.(*syscall.Stat_t)
|
||||
if !ok {
|
||||
return si
|
||||
}
|
||||
st.Atim = syscall.Timespec{}
|
||||
return st
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue