Skip to content

Commit

Permalink
Fix the issue that the expires shortened after merging cloned mirror (#…
Browse files Browse the repository at this point in the history
…1051)

Co-authored-by: Ti Prow Robot <71242396+ti-community-prow-bot@users.noreply.github.com>
  • Loading branch information
lucklove and ti-chi-bot authored Jan 13, 2021
1 parent 5dd25ae commit fdc32c5
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions pkg/repository/v1manifest/manifest.go
Original file line number Diff line number Diff line change
Expand Up @@ -420,9 +420,18 @@ func RenewManifest(m ValidManifest, startTime time.Time) {
if m.Base().Version > 0 {
m.Base().Version++
}
m.Base().Expires = startTime.Add(
ManifestsConfig[m.Base().Ty].Expire,
).Format(time.RFC3339)

// only update expire field when it's old than target expire time
targetExpire := startTime.Add(ManifestsConfig[m.Base().Ty].Expire)
currentExpire, err := time.Parse(time.RFC3339, m.Base().Expires)
if err != nil {
m.Base().Expires = targetExpire.Format(time.RFC3339)
return
}

if currentExpire.Before(targetExpire) {
m.Base().Expires = targetExpire.Format(time.RFC3339)
}
}

// loadKeys stores all keys declared in manifest into ks.
Expand Down

0 comments on commit fdc32c5

Please sign in to comment.