mirror of
https://github.com/osmarks/mycorrhiza.git
synced 2024-10-30 03:36:16 +00:00
Play with stuff
This commit is contained in:
parent
1c317e39aa
commit
d0dbbe4714
@ -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
|
||||
}
|
||||
|
@ -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.
|
||||
|
@ -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"
|
||||
}
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user