Simplify the logic to determine whether to publish the root

Signed-off-by: Ying Li <ying.li@docker.com>
This commit is contained in:
Ying Li 2015-12-09 09:59:08 -08:00
parent 642cf7f353
commit d0e789740a
1 changed files with 4 additions and 9 deletions

View File

@ -353,11 +353,9 @@ func (r *NotaryRepository) Publish() error {
return err return err
} }
// We had local data but the server doesn't know about the repo yet, // We had local data but the server doesn't know about the repo yet,
// ensure we will push the initial root file // ensure we will push the initial root file. The root may not
root, err = r.tufRepo.Root.ToSigned() // be marked as Dirty, since there may not be any changes that
if err != nil { // update it, so use a different boolean.
return err
}
updateRoot = true updateRoot = true
} else { } else {
// The remote store returned an error other than 404. We're // The remote store returned an error other than 404. We're
@ -393,12 +391,9 @@ func (r *NotaryRepository) Publish() error {
update := make(map[string][]byte) update := make(map[string][]byte)
// check if our root file is nearing expiry. Resign if it is. // check if our root file is nearing expiry. Resign if it is.
if nearExpiry(r.tufRepo.Root) || r.tufRepo.Root.Dirty { if nearExpiry(r.tufRepo.Root) || r.tufRepo.Root.Dirty || updateRoot {
root, err = r.tufRepo.SignRoot(data.DefaultExpires("root")) root, err = r.tufRepo.SignRoot(data.DefaultExpires("root"))
updateRoot = true
}
if updateRoot {
rootJSON, err := json.Marshal(root) rootJSON, err := json.Marshal(root)
if err != nil { if err != nil {
return err return err