mirror of
https://github.com/clearlinux/docker.git
synced 2026-08-19 12:16:30 +00:00
Fix a bug which caused repository metadata to be cleared at startup
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user