1
0
mirror of https://github.com/osmarks/mycorrhiza.git synced 2025-12-01 22:28:05 +00:00

Play with stuff

This commit is contained in:
Timur Ismagilov
2022-02-04 03:39:21 +05:00
committed by Timur Ismagilov
parent 1c317e39aa
commit d0dbbe4714
4 changed files with 8 additions and 10 deletions

View File

@@ -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
}

View File

@@ -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.