Commit 4ebb66c6 authored by Josh Yan's avatar Josh Yan
Browse files

reformat error check

parent 23e899f3
...@@ -77,19 +77,20 @@ func cleanupTmpDirs() { ...@@ -77,19 +77,20 @@ func cleanupTmpDirs() {
continue continue
} }
raw, err := os.ReadFile(filepath.Join(d, "ollama.pid")) raw, err := os.ReadFile(filepath.Join(d, "ollama.pid"))
if err == nil { if err != nil {
pid, err := strconv.Atoi(string(raw)) slog.Warn("failed to read ollama.pid", "path", d, "error", err)
if err == nil {
if proc, err := os.FindProcess(pid); err == nil && !errors.Is(proc.Signal(syscall.Signal(0)), os.ErrProcessDone) {
// Another running ollama, ignore this tmpdir
continue
}
}
} else {
slog.Debug("failed to open ollama.pid", "path", d, "error", err)
// No pid, ignore this tmpdir // No pid, ignore this tmpdir
continue continue
} }
pid, err := strconv.Atoi(string(raw))
if err == nil {
if proc, err := os.FindProcess(pid); err == nil && !errors.Is(proc.Signal(syscall.Signal(0)), os.ErrProcessDone) {
// Another running ollama, ignore this tmpdir
continue
}
}
err = os.RemoveAll(d) err = os.RemoveAll(d)
if err != nil { if err != nil {
slog.Debug("unable to cleanup stale tmpdir", "path", d, "error", err) slog.Debug("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