Skip to content

Commit

Permalink
Merge pull request #159 from veraicon/fixManifestCompare
Browse files Browse the repository at this point in the history
修复manifestEqual方法缺陷
  • Loading branch information
denverdino authored Aug 29, 2024
2 parents 18f32f5 + 83414dd commit 20f6a24
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions pkg/sync/destination.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package sync

import (
"bytes"
"context"
"encoding/json"
"fmt"
"io"
"reflect"
"strings"

"github.com/AliyunContainerService/image-syncer/pkg/utils/auth"
Expand Down Expand Up @@ -214,11 +214,16 @@ func (i *ImageDestination) String() string {
}

func manifestEqual(m1, m2 []byte) bool {
var a bytes.Buffer
_ = json.Compact(&a, m1)
var a map[string]interface{}
var b map[string]interface{}

var b bytes.Buffer
_ = json.Compact(&b, m2)
if err := json.Unmarshal(m1, &a); err != nil {
//Received an unexpected manifest retrieval result, return false to trigger a fallback to the push task.
return false
}
if err := json.Unmarshal(m2, &b); err != nil {
return false
}

return a.String() == b.String()
return reflect.DeepEqual(a, b)
}

0 comments on commit 20f6a24

Please sign in to comment.