Update nanosecond diff comparison

Only check content of files if both files have zero nanosecond times.
A zero nanosecond time is considered ambiguous as to whether or
not the timestamp has been truncated by tar. Previously the diff
algorithm was attempting to account for comparisons from a source
to a directory with an applied tar. This condition is no longer
relevant since there is no support for recreating tars directories
which have had a tar extracted. In the case where the older directory
has a truncated timestamp and the newer one does not, this may always
be considered a change. In the case where both are zero, treat the
timestamp as ambiguous and compare content.

Signed-off-by: Derek McGowan <derek@mcgstyle.net>
This commit is contained in:
Derek McGowan
2017-12-26 13:03:20 -08:00
parent c07ede497d
commit 88d59d37fa
2 changed files with 16 additions and 7 deletions

View File

@@ -71,9 +71,9 @@ func sameFile(f1, f2 *currentPath) (bool, error) {
return false, nil
}
// If the timestamp may have been truncated in one of the
// If the timestamp may have been truncated in both of the
// files, check content of file to determine difference
if t1.Nanosecond() == 0 || t2.Nanosecond() == 0 {
if t1.Nanosecond() == 0 && t2.Nanosecond() == 0 {
var eq bool
if (f1.f.Mode() & os.ModeSymlink) == os.ModeSymlink {
eq, err = compareSymlinkTarget(f1.fullPath, f2.fullPath)