mirror of
https://github.com/osmarks/mycorrhiza.git
synced 2025-01-19 07:02:51 +00:00
Fix the locking bug with CRUD operations
This commit is contained in:
parent
ee02211b3e
commit
c7024da735
@ -92,7 +92,7 @@ func factoryHandlerConfirmer(
|
||||
return func(w http.ResponseWriter, rq *http.Request) {
|
||||
log.Println(rq.URL)
|
||||
var (
|
||||
hyphaName = HyphaNameFromRq(rq, "unattach-confirm")
|
||||
hyphaName = HyphaNameFromRq(rq, actionPath)
|
||||
h = hyphae.ByName(hyphaName)
|
||||
u = user.FromRequest(rq)
|
||||
)
|
||||
|
@ -31,8 +31,6 @@ func (h *Hypha) CanDelete(u *user.User) (err error, errtitle string) {
|
||||
|
||||
// DeleteHypha deletes hypha and makes a history record about that.
|
||||
func (h *Hypha) DeleteHypha(u *user.User) (hop *history.HistoryOp, errtitle string) {
|
||||
h.Lock()
|
||||
defer h.Unlock()
|
||||
hop = history.Operation(history.TypeDeleteHypha)
|
||||
|
||||
if err, errtitle := h.CanDelete(u); errtitle != "" {
|
||||
|
@ -50,8 +50,6 @@ func canRenameThisToThat(oh *Hypha, nh *Hypha, u *user.User) (err error, errtitl
|
||||
|
||||
// RenameHypha renames hypha from old name `hyphaName` to `newName` and makes a history record about that. If `recursive` is `true`, its subhyphae will be renamed the same way.
|
||||
func (h *Hypha) RenameHypha(newHypha *Hypha, recursive bool, u *user.User) (hop *history.HistoryOp, errtitle string) {
|
||||
h.Lock()
|
||||
defer h.Unlock()
|
||||
newHypha.Lock()
|
||||
defer newHypha.Unlock()
|
||||
hop = history.Operation(history.TypeRenameHypha)
|
||||
|
@ -35,8 +35,6 @@ func (h *Hypha) CanUnattach(u *user.User) (err error, errtitle string) {
|
||||
|
||||
// UnattachHypha unattaches hypha and makes a history record about that.
|
||||
func (h *Hypha) UnattachHypha(u *user.User) (hop *history.HistoryOp, errtitle string) {
|
||||
h.Lock()
|
||||
defer h.Unlock()
|
||||
hop = history.Operation(history.TypeUnattachHypha)
|
||||
|
||||
if err, errtitle := h.CanUnattach(u); errtitle != "" {
|
||||
|
3
name.go
3
name.go
@ -47,8 +47,7 @@ func HyphaNameFromRq(rq *http.Request, actions ...string) string {
|
||||
return util.CanonicalName(strings.TrimPrefix(p, "/"+action+"/"))
|
||||
}
|
||||
}
|
||||
log.Fatal("HyphaNameFromRq: no matching action passed")
|
||||
return ""
|
||||
panic("HyphaNameFromRq: no matching action passed")
|
||||
}
|
||||
|
||||
// geminiHyphaNameFromRq extracts hypha name from gemini request. You have to also pass the action which is embedded in the url or several actions. For url /hypha/hypha, the action would be "hypha".
|
||||
|
Loading…
Reference in New Issue
Block a user