Skip to content

Commit f682261

Browse files
committed
limactl stop: remove *.tmp
Signed-off-by: Akihiro Suda <[email protected]>
1 parent 8498a19 commit f682261

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

cmd/limactl/stop.go

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -133,18 +133,21 @@ func stopInstanceForcibly(inst *store.Instance) {
133133
logrus.Info("The host agent process seems already stopped")
134134
}
135135

136-
logrus.Infof("Removing *.pid *.sock under %q", inst.Dir)
136+
suffixesToBeRemoved := []string{".pid", ".sock", ".tmp"}
137+
logrus.Infof("Removing %s under %q", inst.Dir, strings.ReplaceAll(strings.Join(suffixesToBeRemoved, " "), ".", "*."))
137138
fi, err := os.ReadDir(inst.Dir)
138139
if err != nil {
139140
logrus.Error(err)
140141
return
141142
}
142143
for _, f := range fi {
143144
path := filepath.Join(inst.Dir, f.Name())
144-
if strings.HasSuffix(path, ".pid") || strings.HasSuffix(path, ".sock") {
145-
logrus.Infof("Removing %q", path)
146-
if err := os.Remove(path); err != nil {
147-
logrus.Error(err)
145+
for _, suffix := range suffixesToBeRemoved {
146+
if strings.HasSuffix(path, suffix) {
147+
logrus.Infof("Removing %q", path)
148+
if err := os.Remove(path); err != nil {
149+
logrus.Error(err)
150+
}
148151
}
149152
}
150153
}

0 commit comments

Comments
 (0)