diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2020-03-16 13:48:36 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-16 13:48:36 +0100 |
commit | 5288d112bc63bb52821a0ed9711fcc23b37df2a8 (patch) | |
tree | 0919c02b3d121bd17cbb4bea5f5af905248a2224 /libpod | |
parent | 759ffb0a27d477fe6705f4cc9b9b83cd7f0cc6e7 (diff) | |
parent | d4540e07c73ed5576f42f653781e1af19d8b1f0d (diff) | |
download | podman-5288d112bc63bb52821a0ed9711fcc23b37df2a8.tar.gz podman-5288d112bc63bb52821a0ed9711fcc23b37df2a8.tar.bz2 podman-5288d112bc63bb52821a0ed9711fcc23b37df2a8.zip |
Merge pull request #5252 from QiWang19/not-reset-tempdir
Fix bug podman reset to not remove $XDG_RUNTIME_DIR
Diffstat (limited to 'libpod')
-rw-r--r-- | libpod/reset.go | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/libpod/reset.go b/libpod/reset.go index a35b476a4..ae0a0cde9 100644 --- a/libpod/reset.go +++ b/libpod/reset.go @@ -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 { |