Sfoglia il codice sorgente

reformat error check

Josh Yan 10 mesi fa
parent
commit
4ebb66c662
1 ha cambiato i file con 11 aggiunte e 10 eliminazioni
  1. 11 10
      gpu/assets.go

+ 11 - 10
gpu/assets.go

@@ -77,19 +77,20 @@ func cleanupTmpDirs() {
 			continue
 		}
 		raw, err := os.ReadFile(filepath.Join(d, "ollama.pid"))
-		if err == nil {
-			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
-				}
-			}
-		} else {
-			slog.Debug("failed to open ollama.pid", "path", d, "error", err)
+		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))
+		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)
 		if err != nil {
 			slog.Debug("unable to cleanup stale tmpdir", "path", d, "error", err)