Fixed a bug which caused dockerd to not create its DB if an empty /var/lib/docker/images existed; fixed a bug which caused dockerd to not create missing tables in the images DB.

This commit is contained in:
Solomon Hykes 2013-03-09 19:56:33 -08:00
parent 4474cd5677
commit b5b2f005eb

View file

@ -4,9 +4,9 @@ import (
"database/sql"
"errors"
"fmt"
"github.com/coopernurse/gorp"
"github.com/dotcloud/docker/future"
_ "github.com/mattn/go-sqlite3"
"github.com/shykes/gorp" //Forked to implement CreateTablesOpts
"io"
"os"
"path"
@ -29,8 +29,6 @@ func New(root string) (*Store, error) {
if err := os.Mkdir(root, 0700); err != nil && !os.IsExist(err) {
return nil, err
} else if os.IsExist(err) {
isNewStore = false
}
db, err := sql.Open("sqlite3", path.Join(root, "db"))
if err != nil {
@ -42,7 +40,7 @@ func New(root string) (*Store, error) {
orm.AddTableWithName(Mountpoint{}, "mountpoints").SetKeys(false, "Root")
orm.AddTableWithName(Tag{}, "tags").SetKeys(false, "TagName")
if isNewStore {
if err := orm.CreateTables(); err != nil {
if err := orm.CreateTablesOpts(true); err != nil {
return nil, err
}
}