sketch/loop: fuss more with /git/cat and 204s
For unknown reasons, switching to 204s made the diff view noticeably slower.
Be more explicit about things in the hope that it helps.
Co-Authored-By: sketch <hello@sketch.dev>
Change-ID: s52c5ab6557e1f9dbk
diff --git a/loop/server/loophttp.go b/loop/server/loophttp.go
index 550760c..6fa3aae 100644
--- a/loop/server/loophttp.go
+++ b/loop/server/loophttp.go
@@ -1443,12 +1443,14 @@
// Get file content using GitCat
content, err := git_tools.GitCat(repoDir, path)
- if errors.Is(err, os.ErrNotExist) {
+ switch {
+ case err == nil:
+ // continued below
+ case errors.Is(err, os.ErrNotExist), strings.Contains(err.Error(), "not tracked by git"):
w.WriteHeader(http.StatusNoContent)
return
- }
- if err != nil {
- http.Error(w, fmt.Sprintf("Error reading file: %v", err), http.StatusInternalServerError)
+ default:
+ http.Error(w, fmt.Sprintf("error reading file: %v", err), http.StatusInternalServerError)
return
}