mirror of
https://github.com/containers/podman.git
synced 2025-12-01 18:49:18 +08:00
... to include https://github.com/containers/image/pull/2173, https://github.com/containers/common/pull/1731 and https://github.com/containers/buildah/pull/5143 . Signed-off-by: Miloslav Trmač <mitr@redhat.com>
27 lines
601 B
Go
27 lines
601 B
Go
package tmpdir
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
|
|
"github.com/containers/common/pkg/config"
|
|
"github.com/sirupsen/logrus"
|
|
)
|
|
|
|
// GetTempDir returns the path of the preferred temporary directory on the host.
|
|
func GetTempDir() string {
|
|
if tmpdir, ok := os.LookupEnv("TMPDIR"); ok {
|
|
abs, err := filepath.Abs(tmpdir)
|
|
if err == nil {
|
|
return abs
|
|
}
|
|
logrus.Warnf("ignoring TMPDIR from environment, evaluating it: %v", err)
|
|
}
|
|
if containerConfig, err := config.Default(); err == nil {
|
|
if tmpdir, err := containerConfig.ImageCopyTmpDir(); err == nil {
|
|
return tmpdir
|
|
}
|
|
}
|
|
return "/var/tmp"
|
|
}
|