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

Fix the issue that the expires shortened after merging cloned mirror #1051

Merged
merged 8 commits into from
Jan 13, 2021
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