mirror of
https://github.com/osmarks/mycorrhiza.git
synced 2024-12-13 05:50:27 +00:00
Fix a bug related to hyphae that have amnts but no text
This commit is contained in:
parent
c7024da735
commit
77688b3869
@ -107,9 +107,6 @@ func EmptyHypha(hyphaName string) *Hypha {
|
||||
|
||||
// ByName returns a hypha by name. If h.Exists, the returned hypha pointer is known to be part of the hypha index (byNames map).
|
||||
func ByName(hyphaName string) (h *Hypha) {
|
||||
byNamesMutex.Lock()
|
||||
defer byNamesMutex.Unlock()
|
||||
|
||||
h, exists := byNames[hyphaName]
|
||||
if exists {
|
||||
return h
|
||||
@ -119,22 +116,23 @@ func ByName(hyphaName string) (h *Hypha) {
|
||||
|
||||
// Insert inserts the hypha into the storage. It overwrites the previous record, if there was any, and returns false. If the was no previous record, return true.
|
||||
func (h *Hypha) Insert() (justCreated bool) {
|
||||
var hp *Hypha
|
||||
hp = ByName(h.Name)
|
||||
hp := ByName(h.Name)
|
||||
|
||||
byNamesMutex.Lock()
|
||||
defer byNamesMutex.Unlock()
|
||||
if hp.Exists {
|
||||
hp = h
|
||||
} else {
|
||||
byNames[hp.Name] = h
|
||||
h.Exists = true
|
||||
byNames[h.Name] = h
|
||||
IncrementCount()
|
||||
}
|
||||
|
||||
return !hp.Exists
|
||||
}
|
||||
|
||||
func (h *Hypha) InsertIfNew() (justCreated bool) {
|
||||
if h.Exists {
|
||||
if !h.Exists {
|
||||
return h.Insert()
|
||||
}
|
||||
return false
|
||||
|
@ -114,9 +114,9 @@ func (h *Hypha) uploadHelp(hop *history.HistoryOp, ext string, data []byte, u *u
|
||||
}
|
||||
|
||||
h.InsertIfNew()
|
||||
*originalFullPath = fullPath
|
||||
if h.Exists && hop.Type == history.TypeEditText && !history.FileChanged(fullPath) {
|
||||
if h.Exists && h.TextPath != "" && hop.Type == history.TypeEditText && !history.FileChanged(fullPath) {
|
||||
return hop.Abort(), "No changes"
|
||||
}
|
||||
*originalFullPath = fullPath
|
||||
return hop.WithFiles(fullPath).WithUser(u).Apply(), ""
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user