1
0
mirror of https://github.com/osmarks/mycorrhiza.git synced 2025-01-05 17:40:26 +00:00

Fix revision texts for deleted hyphae

I dislike every part related to git
This commit is contained in:
Timur Ismagilov 2022-05-31 13:36:57 +03:00
parent 9e99e8da11
commit 913f85b440

View File

@ -67,8 +67,18 @@ func handlerRevisionText(w http.ResponseWriter, rq *http.Request) {
w.Header().Set("Content-Type", "text/plain; charset=utf-8")
switch h := h.(type) {
case *hyphae.EmptyHypha:
log.Printf(`Hypha %s does not exist`)
w.WriteHeader(http.StatusNotFound)
var mycoFilePath = filepath.Join(files.HyphaeDir(), h.CanonicalName()+".myco")
var textContents, err = history.FileAtRevision(mycoFilePath, revHash)
if err != nil {
w.WriteHeader(http.StatusNotFound)
log.Printf("While serving text of %s at revision %s: %s\n", hyphaName, revHash, err.Error())
_, _ = io.WriteString(w, "Error: "+err.Error())
return
}
log.Printf("Serving text of %s from %s at revision %s\n", hyphaName, mycoFilePath, revHash)
w.WriteHeader(http.StatusOK)
_, _ = io.WriteString(w, textContents)
case hyphae.ExistingHypha:
if !h.HasTextFile() {
log.Printf(`Media hypha %s has no text`)