Merge pull request #5252 from QiWang19/not-reset-tempdir

Fix bug podman reset to not remove $XDG_RUNTIME_DIR
This commit is contained in:
OpenShift Merge Robot 2020-03-16 13:48:36 +01:00 committed by GitHub
commit 5288d112bc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 1 deletions

View File

@ -7,6 +7,7 @@ import (
"github.com/containers/libpod/libpod/define"
"github.com/containers/libpod/pkg/rootless"
"github.com/containers/libpod/pkg/util"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
)
@ -87,12 +88,22 @@ func (r *Runtime) Reset(ctx context.Context) error {
}
prevError = err
}
if err := os.RemoveAll(r.config.TmpDir); err != nil {
runtimeDir, err := util.GetRuntimeDir()
if err != nil {
return err
}
tempDir := r.config.TmpDir
if r.config.TmpDir == runtimeDir {
tempDir = filepath.Join(r.config.TmpDir, "containers")
}
if err := os.RemoveAll(tempDir); err != nil {
if prevError != nil {
logrus.Error(prevError)
}
prevError = err
}
if rootless.IsRootless() {
configPath := filepath.Join(os.Getenv("HOME"), ".config/containers")
if err := os.RemoveAll(configPath); err != nil {