From d0dbbe4714b124c40e8f64f6e44a1c0b72f3a3a7 Mon Sep 17 00:00:00 2001 From: Timur Ismagilov Date: Fri, 4 Feb 2022 03:39:21 +0500 Subject: [PATCH] Play with stuff --- hyphae/files.go | 8 +++----- hyphae/hyphae.go | 6 +++--- shroom/upload.go | 2 +- shroom/view.go | 2 +- 4 files changed, 8 insertions(+), 10 deletions(-) diff --git a/hyphae/files.go b/hyphae/files.go index 55e7f7e..eb58a93 100644 --- a/hyphae/files.go +++ b/hyphae/files.go @@ -23,7 +23,7 @@ func Index(path string) { if oh := ByName(h.name); oh.Exists { oh.mergeIn(h) } else { - h.insert() + insert(h) } } log.Println("Indexed", Count(), "hyphae") @@ -40,10 +40,8 @@ func indexHelper(path string, nestLevel uint, ch chan *Hypha) { for _, node := range nodes { // If this hypha looks like it can be a hypha path, go deeper. Do not - // touch the .git and static folders for they have an administrative - // importance! - if node.IsDir() && IsValidName(node.Name()) && node.Name() != ".git" && - !(nestLevel == 0 && node.Name() == "static") { + // touch the .git folders for it has an administrative importance! + if node.IsDir() && IsValidName(node.Name()) && node.Name() != ".git" { indexHelper(filepath.Join(path, node.Name()), nestLevel+1, ch) continue } diff --git a/hyphae/hyphae.go b/hyphae/hyphae.go index 1d95c2c..f625e3c 100644 --- a/hyphae/hyphae.go +++ b/hyphae/hyphae.go @@ -110,7 +110,7 @@ func storeHypha(h *Hypha) { } // insert inserts the hypha into the storage. A previous record is used if possible. Count incrementation is done if needed. -func (h *Hypha) insert() (madeNewRecord bool) { +func insert(h *Hypha) (madeNewRecord bool) { hp, recorded := byNames[h.name] if recorded { hp.mergeIn(h) @@ -123,11 +123,11 @@ func (h *Hypha) insert() (madeNewRecord bool) { } // InsertIfNew checks whether hypha exists and returns `true` if it didn't and has been created. -func (h *Hypha) InsertIfNew() (madeNewRecord bool) { +func InsertIfNew(h *Hypha) (madeNewRecord bool) { if h.DoesExist() { return false } - return h.insert() + return insert(h) } // RenameTo renames a hypha and performs respective changes in the storage. diff --git a/shroom/upload.go b/shroom/upload.go index 6ffdd3a..899ee8d 100644 --- a/shroom/upload.go +++ b/shroom/upload.go @@ -100,7 +100,7 @@ func uploadHelp(h *hyphae.Hypha, hop *history.Op, ext string, data []byte, u *us log.Println("Move", sourceFullPath, "to", fullPath) } - h.InsertIfNew() + hyphae.InsertIfNew(h) if h.Exists && h.TextPath != "" && hop.Type == history.TypeEditText && !history.FileChanged(fullPath) { return hop.Abort(), "No changes" } diff --git a/shroom/view.go b/shroom/view.go index 1bd22db..01e40cb 100644 --- a/shroom/view.go +++ b/shroom/view.go @@ -9,7 +9,7 @@ import ( // FetchTextPart tries to read text file of the given hypha. If there is no file, empty string is returned. func FetchTextPart(h *hyphae.Hypha) (string, error) { - if h.TextPath == "" { + if !h.HasTextPart() { return "", nil } text, err := os.ReadFile(h.TextPath)