Skip to content

Commit f681eac

Browse files
committed
reduce code complexity
Signed-off-by: Mike Brown <[email protected]>
1 parent 6728803 commit f681eac

1 file changed

Lines changed: 4 additions & 8 deletions

File tree

fs/path.go

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -117,17 +117,13 @@ func sameFile(f1, f2 *currentPath) (bool, error) {
117117
// If the timestamp may have been truncated in both of the
118118
// files, check content of file to determine difference
119119
if t1.Nanosecond() == 0 && t2.Nanosecond() == 0 {
120-
var eq bool
121120
if (f1.f.Mode() & os.ModeSymlink) == os.ModeSymlink {
122-
eq, err = compareSymlinkTarget(f1.fullPath, f2.fullPath)
123-
} else if f1.f.Size() > 0 {
124-
eq, err = compareFileContent(f1.fullPath, f2.fullPath)
125-
} else {
126-
eq, err = true, nil // if file sizes are zero length, the files are the same by definition
121+
return compareSymlinkTarget(f1.fullPath, f2.fullPath)
127122
}
128-
if err != nil || !eq {
129-
return eq, err
123+
if f1.f.Size() == 0 { // if file sizes are zero length, the files are the same by definition
124+
return true, nil
130125
}
126+
return compareFileContent(f1.fullPath, f2.fullPath)
131127
} else if t1.Nanosecond() != t2.Nanosecond() {
132128
return false, nil
133129
}

0 commit comments

Comments
 (0)