From b7cbe04cfc2b0032c8a39a2a11c3b2fbf6403267 Mon Sep 17 00:00:00 2001 From: Timur Ismagilov Date: Fri, 30 Jul 2021 19:16:58 +0500 Subject: [PATCH] Show revisions of deleted hyphae --- hyphae/hyphae.go | 10 ++++++++++ web/readers.go | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/hyphae/hyphae.go b/hyphae/hyphae.go index a8f5bb5..ebd810e 100644 --- a/hyphae/hyphae.go +++ b/hyphae/hyphae.go @@ -2,7 +2,9 @@ package hyphae import ( + "github.com/bouncepaw/mycorrhiza/files" "log" + "path/filepath" "regexp" "sync" ) @@ -19,6 +21,14 @@ type Hypha struct { BinaryPath string // == "" => no attachment } +// TextPartPath returns rooted path to the file where the text part should be. +func (h *Hypha) TextPartPath() string { + if h.TextPath == "" { + return filepath.Join(files.HyphaeDir(), h.Name+".myco") + } + return h.TextPath +} + var byNames = make(map[string]*Hypha) var byNamesMutex = sync.Mutex{} diff --git a/web/readers.go b/web/readers.go index ac22633..f1b797c 100644 --- a/web/readers.go +++ b/web/readers.go @@ -73,7 +73,7 @@ func handlerRevision(w http.ResponseWriter, rq *http.Request) { hyphaName = util.CanonicalName(shorterUrl[firstSlashIndex+1:]) h = hyphae.ByName(hyphaName) contents = fmt.Sprintf(`

This hypha had no text at this revision.

`) - textContents, err = history.FileAtRevision(h.TextPath, revHash) + textContents, err = history.FileAtRevision(h.TextPartPath(), revHash) u = user.FromRequest(rq) ) if err == nil {