From d0c776528b50f884c970cf0563ef6b40d90efc44 Mon Sep 17 00:00:00 2001 From: Solomon Hykes Date: Thu, 21 Mar 2013 19:00:43 -0700 Subject: [PATCH] Fix a bug which caused repository metadata to be cleared at startup --- tags.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tags.go b/tags.go index 908691a8f9..55a5135860 100644 --- a/tags.go +++ b/tags.go @@ -3,6 +3,7 @@ package docker import ( "encoding/json" "io/ioutil" + "os" "path/filepath" ) @@ -24,7 +25,12 @@ func NewTagStore(path string, graph *Graph) (*TagStore, error) { graph: graph, Repositories: make(map[string]Repository), } - if err := store.Save(); err != nil { + // Load the json file if it exists, otherwise create it. + if err := store.Reload(); os.IsNotExist(err) { + if err := store.Save(); err != nil { + return nil, err + } + } else if err != nil { return nil, err } return store, nil