remove root.json after getting the targets

This commit is contained in:
Tan Jiang 2017-03-25 17:00:26 +08:00
parent 851f61032a
commit 5e2598028f

View File

@ -16,6 +16,8 @@
package notary
import (
"os"
"path"
"strings"
"github.com/docker/notary"
@ -74,6 +76,12 @@ func GetTargets(notaryEndpoint string, username string, fqRepo string) ([]Target
} else if err != nil {
return res, err
}
//Remove root.json such that when remote repository is removed the local cache can't be reused.
rootJSON := path.Join(notaryCachePath, "tuf", fqRepo, "metadata/root.json")
rmErr := os.Remove(rootJSON)
if rmErr != nil {
log.Warningf("Failed to clear cached root.json: %s, error: %v, when repo is removed from notary the signature status maybe incorrect")
}
for _, t := range targets {
res = append(res, Target{t.Name, t.Hashes})
}