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

reformat error check

parent 23e899f3
...@@ -77,7 +77,12 @@ func cleanupTmpDirs() { ...@@ -77,7 +77,12 @@ 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 {
slog.Warn("failed to read ollama.pid", "path", d, "error", err)
// No pid, ignore this tmpdir
continue
}
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) { if proc, err := os.FindProcess(pid); err == nil && !errors.Is(proc.Signal(syscall.Signal(0)), os.ErrProcessDone) {
...@@ -85,11 +90,7 @@ func cleanupTmpDirs() { ...@@ -85,11 +90,7 @@ func cleanupTmpDirs() {
continue continue
} }
} }
} else {
slog.Debug("failed to open ollama.pid", "path", d, "error", err)
// No pid, 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