From 5e2598028fcb429f1c12e4d3764f7c799306cd58 Mon Sep 17 00:00:00 2001 From: Tan Jiang Date: Sat, 25 Mar 2017 17:00:26 +0800 Subject: [PATCH] remove root.json after getting the targets --- src/common/utils/notary/helper.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/common/utils/notary/helper.go b/src/common/utils/notary/helper.go index 0c6be9fc6..3430d7b63 100644 --- a/src/common/utils/notary/helper.go +++ b/src/common/utils/notary/helper.go @@ -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}) }