diff --git a/cmd/diff-main.go b/cmd/diff-main.go index 64953d94..d3610db7 100644 --- a/cmd/diff-main.go +++ b/cmd/diff-main.go @@ -91,6 +91,8 @@ func (d diffMessage) String() string { msg = console.Colorize("DiffType", "! "+d.SecondURL) case differInSize: msg = console.Colorize("DiffSize", "! "+d.SecondURL) + case differInTime: + msg = console.Colorize("DiffTime", "! "+d.SecondURL) default: fatalIf(errDummy().Trace(d.FirstURL, d.SecondURL), "Unhandled difference between `"+d.FirstURL+"` and `"+d.SecondURL+"`.") @@ -198,6 +200,7 @@ func mainDiff(ctx *cli.Context) error { console.SetColor("DiffOnlyInSecond", color.New(color.FgGreen)) console.SetColor("DiffType", color.New(color.FgMagenta)) console.SetColor("DiffSize", color.New(color.FgYellow, color.Bold)) + console.SetColor("DiffTime", color.New(color.FgYellow, color.Bold)) URLs := ctx.Args() firstURL := URLs.Get(0) diff --git a/cmd/difference.go b/cmd/difference.go index a7f09530..3222ddbe 100644 --- a/cmd/difference.go +++ b/cmd/difference.go @@ -29,6 +29,7 @@ type differType int const ( differInNone differType = iota // does not differ differInSize // differs in size + differInTime // differs in time differInType // only in source differInFirst // only in target differInSecond // differs in type, exfile/directory @@ -40,6 +41,8 @@ func (d differType) String() string { return "" case differInSize: return "size" + case differInTime: + return "time" case differInType: return "type" case differInFirst: @@ -161,9 +164,10 @@ func difference(sourceClnt, targetClnt Client, sourceURL, targetURL string, isRe if normalizedExpected == normalizedCurrent { srcType, tgtType := srcCtnt.Type, tgtCtnt.Type srcSize, tgtSize := srcCtnt.Size, tgtCtnt.Size + srcTime, tgtTime := srcCtnt.Time, tgtCtnt.Time if srcType.IsRegular() && !tgtType.IsRegular() || !srcType.IsRegular() && tgtType.IsRegular() { - // Type differes. Source is never a directory. + // Type differs. Source is never a directory. diffCh <- diffMessage{ FirstURL: srcCtnt.URL.String(), SecondURL: tgtCtnt.URL.String(), @@ -171,7 +175,9 @@ func difference(sourceClnt, targetClnt Client, sourceURL, targetURL string, isRe firstContent: srcCtnt, secondContent: tgtCtnt, } - } else if (srcType.IsRegular() && tgtType.IsRegular()) && srcSize != tgtSize { + continue + } + if (srcType.IsRegular() && tgtType.IsRegular()) && srcSize != tgtSize { // Regular files differing in size. diffCh <- diffMessage{ FirstURL: srcCtnt.URL.String(), @@ -180,6 +186,15 @@ func difference(sourceClnt, targetClnt Client, sourceURL, targetURL string, isRe firstContent: srcCtnt, secondContent: tgtCtnt, } + } else if srcTime.After(tgtTime) { + // Regular files differing in timestamp. + diffCh <- diffMessage{ + FirstURL: srcCtnt.URL.String(), + SecondURL: tgtCtnt.URL.String(), + Diff: differInTime, + firstContent: srcCtnt, + secondContent: tgtCtnt, + } } // No differ if returnSimilar { diff --git a/cmd/mirror-url.go b/cmd/mirror-url.go index 6a6e096b..e591fc29 100644 --- a/cmd/mirror-url.go +++ b/cmd/mirror-url.go @@ -108,7 +108,7 @@ func deltaSourceTarget(sourceURL string, targetURL string, isForce bool, isFake case differInType: URLsCh <- URLs{Error: errInvalidTarget(diffMsg.SecondURL)} continue - case differInSize: + case differInSize, differInTime: if !isForce && !isFake { // Size differs and force not set URLsCh <- URLs{Error: errOverWriteNotAllowed(diffMsg.SecondURL)}