Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

diff: Disable comparing modtimes when multimaster context is not found #3226

Merged
merged 1 commit into from May 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 4 additions & 1 deletion cmd/diff-main.go
Expand Up @@ -90,6 +90,8 @@ func (d diffMessage) String() string {
msg = console.Colorize("DiffSize", "! "+d.SecondURL)
case differInMetadata:
msg = console.Colorize("DiffMetadata", "! "+d.SecondURL)
case differInMMSourceMTime:
msg = console.Colorize("DiffMMSourceMTime", "! "+d.SecondURL)
default:
fatalIf(errDummy().Trace(d.FirstURL, d.SecondURL),
"Unhandled difference between `"+d.FirstURL+"` and `"+d.SecondURL+"`.")
Expand Down Expand Up @@ -201,7 +203,8 @@ 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))
console.SetColor("DiffMetadata", color.New(color.FgYellow, color.Bold))
console.SetColor("DiffMMSourceMTime", color.New(color.FgYellow, color.Bold))

URLs := ctx.Args()
firstURL := URLs.Get(0)
Expand Down
9 changes: 8 additions & 1 deletion cmd/difference.go
Expand Up @@ -34,11 +34,11 @@ type differType int
const (
differInNone differType = iota // does not differ
differInSize // differs in size
differInMMSourceMTime // differs in multi-master source modtime
differInMetadata // differs in metadata
differInType // differs in type, exfile/directory
differInFirst // only in source (FIRST)
differInSecond // only in target (SECOND)
differInMMSourceMTime // differs in multi-master source modtime
)

func (d differType) String() string {
Expand Down Expand Up @@ -91,6 +91,13 @@ func multiMasterModTimeUpdated(src, dst *ClientContent) bool {
return false
}

_, ok1 := src.UserMetadata[multiMasterSourceModTimeKey]
_, ok2 := dst.UserMetadata[multiMasterSourceModTimeKey]
if !ok1 && !ok2 {
// No multimaster context found, consider src & dst as similar
return false
}

srcOriginLastModified, _ := time.Parse(time.RFC3339Nano, src.UserMetadata[multiMasterSourceModTimeKey])
dstOriginLastModified, _ := time.Parse(time.RFC3339Nano, dst.UserMetadata[multiMasterSourceModTimeKey])

Expand Down