Ensure directory where we will make database exists

Ensure that the directory where we will create the Podman db
exists prior to creating the database - otherwise creating the DB
will fail.

Signed-off-by: Matthew Heon <mheon@redhat.com>
This commit is contained in:
Matthew Heon
2018-12-03 11:07:01 -05:00
parent ea13264958
commit 677c444463

View File

@ -472,6 +472,15 @@ func makeRuntime(runtime *Runtime) (err error) {
runtime.config.ConmonPath) runtime.config.ConmonPath)
} }
// Make the static files directory if it does not exist
if err := os.MkdirAll(runtime.config.StaticDir, 0700); err != nil {
// The directory is allowed to exist
if !os.IsExist(err) {
return errors.Wrapf(err, "error creating runtime static files directory %s",
runtime.config.StaticDir)
}
}
// Set up the state // Set up the state
switch runtime.config.StateType { switch runtime.config.StateType {
case InMemoryStateStore: case InMemoryStateStore:
@ -601,15 +610,6 @@ func makeRuntime(runtime *Runtime) (err error) {
} }
runtime.ociRuntime = ociRuntime runtime.ociRuntime = ociRuntime
// Make the static files directory if it does not exist
if err := os.MkdirAll(runtime.config.StaticDir, 0755); err != nil {
// The directory is allowed to exist
if !os.IsExist(err) {
return errors.Wrapf(err, "error creating runtime static files directory %s",
runtime.config.StaticDir)
}
}
// Make a directory to hold container lockfiles // Make a directory to hold container lockfiles
lockDir := filepath.Join(runtime.config.TmpDir, "lock") lockDir := filepath.Join(runtime.config.TmpDir, "lock")
if err := os.MkdirAll(lockDir, 0755); err != nil { if err := os.MkdirAll(lockDir, 0755); err != nil {