2
2
mirror of https://github.com/octoleo/restic.git synced 2024-12-22 02:48:55 +00:00

Darwin test fix: allow 1μs timestamp difference

On Darwin, allow a 1μs difference in restored timestamps, because
macOS <10.13 cannot restore with nanosecond precision and the current
version of Go (1.9.2) does not yet support the new syscall required
for this. (#1087 #1389)
This commit is contained in:
Konrad Wojas 2017-10-29 20:48:07 +08:00
parent e44ac55f63
commit f3016a9096

View File

@ -71,7 +71,17 @@ func sameModTime(fi1, fi2 os.FileInfo) bool {
}
}
return fi1.ModTime().Equal(fi2.ModTime())
same := fi1.ModTime().Equal(fi2.ModTime())
if !same && runtime.GOOS == "darwin" {
// Allow up to 1μs difference, because macOS <10.13 cannot restore
// with nanosecond precision and the current version of Go (1.9.2)
// does not yet support the new syscall. (#1087)
mt1 := fi1.ModTime()
mt2 := fi2.ModTime()
usecDiff := (mt1.Nanosecond()-mt2.Nanosecond())/1000 + (mt1.Second()-mt2.Second())*1000000
same = usecDiff <= 1 && usecDiff >= -1
}
return same
}
// directoriesEqualContents checks if both directories contain exactly the same