From 06553a756b564ac31acd6a2f6116344cae27b032 Mon Sep 17 00:00:00 2001 From: Charles Hooper Date: Thu, 14 Mar 2013 01:48:50 +0000 Subject: [PATCH] Create docker directories *before* allocating a LayerStore --- docker.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/docker.go b/docker.go index 8e8b19082a..4fc286fefb 100644 --- a/docker.go +++ b/docker.go @@ -109,6 +109,12 @@ func New() (*Docker, error) { } func NewFromDirectory(root string) (*Docker, error) { + docker_repo := path.Join(root, "containers") + + if err := os.MkdirAll(docker_repo, 0700); err != nil && !os.IsExist(err) { + return nil, err + } + store, err := fs.New(path.Join(root, "images")) if err != nil { return nil, err @@ -120,16 +126,12 @@ func NewFromDirectory(root string) (*Docker, error) { docker := &Docker{ root: root, - repository: path.Join(root, "containers"), + repository: docker_repo, containers: list.New(), Store: store, networkManager: netManager, } - if err := os.MkdirAll(docker.repository, 0700); err != nil && !os.IsExist(err) { - return nil, err - } - if err := docker.restore(); err != nil { return nil, err }