Commit 662568d4 authored by Josh Yan's avatar Josh Yan
Browse files

err!=nil check

parent 4ebb66c6
...@@ -84,16 +84,20 @@ func cleanupTmpDirs() { ...@@ -84,16 +84,20 @@ func cleanupTmpDirs() {
} }
pid, err := strconv.Atoi(string(raw)) pid, err := strconv.Atoi(string(raw))
if err == nil { if err != nil {
if proc, err := os.FindProcess(pid); err == nil && !errors.Is(proc.Signal(syscall.Signal(0)), os.ErrProcessDone) { slog.Warn("failed to parse pid", "path", d, "error", err)
// Another running ollama, ignore this tmpdir continue
continue
}
} }
err = os.RemoveAll(d) proc, err := os.FindProcess(pid)
if err != nil { if err == nil && !errors.Is(proc.Signal(syscall.Signal(0)), os.ErrProcessDone) {
slog.Debug("unable to cleanup stale tmpdir", "path", d, "error", err) slog.Warn("found running ollama", "pid", pid, "path", d)
// Another running ollama, ignore this tmpdir
continue
}
if err := os.Remove(d); err != nil {
slog.Warn("unable to cleanup stale tmpdir", "path", d, "error", err)
} }
} }
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment