Refactor utils/tmpdir.go, fixes #11905
Signed-off-by: Antonio Murdaca <me@runcom.ninja>
This commit is contained in:
parent
1f27ebc2c7
commit
f1bbc1f34f
|
@ -857,8 +857,8 @@ func NewDaemonFromDirectory(config *Config, eng *engine.Engine) (*Daemon, error)
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// set up the TempDir to use a canonical path
|
// set up the tmpDir to use a canonical path
|
||||||
tmp, err := utils.TempDir(config.Root)
|
tmp, err := tempDir(config.Root)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("Unable to get the TempDir under %s: %s", config.Root, err)
|
return nil, fmt.Errorf("Unable to get the TempDir under %s: %s", config.Root, err)
|
||||||
}
|
}
|
||||||
|
@ -1246,6 +1246,16 @@ func (daemon *Daemon) ImageGetCached(imgID string, config *runconfig.Config) (*i
|
||||||
return match, nil
|
return match, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// tempDir returns the default directory to use for temporary files.
|
||||||
|
func tempDir(rootDir string) (string, error) {
|
||||||
|
var tmpDir string
|
||||||
|
if tmpDir = os.Getenv("DOCKER_TMPDIR"); tmpDir == "" {
|
||||||
|
tmpDir = filepath.Join(rootDir, "tmp")
|
||||||
|
}
|
||||||
|
err := os.MkdirAll(tmpDir, 0700)
|
||||||
|
return tmpDir, err
|
||||||
|
}
|
||||||
|
|
||||||
func checkKernel() error {
|
func checkKernel() error {
|
||||||
// Check for unsupported kernel versions
|
// Check for unsupported kernel versions
|
||||||
// FIXME: it would be cleaner to not test for specific versions, but rather
|
// FIXME: it would be cleaner to not test for specific versions, but rather
|
||||||
|
|
|
@ -1,16 +0,0 @@
|
||||||
package utils
|
|
||||||
|
|
||||||
import (
|
|
||||||
"os"
|
|
||||||
"path/filepath"
|
|
||||||
)
|
|
||||||
|
|
||||||
// TempDir returns the default directory to use for temporary files.
|
|
||||||
func TempDir(rootDir string) (string, error) {
|
|
||||||
var tmpDir string
|
|
||||||
if tmpDir = os.Getenv("DOCKER_TMPDIR"); tmpDir == "" {
|
|
||||||
tmpDir = filepath.Join(rootDir, "tmp")
|
|
||||||
}
|
|
||||||
err := os.MkdirAll(tmpDir, 0700)
|
|
||||||
return tmpDir, err
|
|
||||||
}
|
|
Loading…
Reference in New Issue