diff --git a/README.md b/README.md index e87ddfc..b1ea98a 100644 --- a/README.md +++ b/README.md @@ -4,9 +4,9 @@ A wiki engine. ## 0.9 This is a development branch for 0.9 version. Features I want to implement in this release: * [x] Recent changes page. -* [ ] Hypha deletion. +* [x] Hypha deletion. * [ ] Hypha renaming. -* [ ] Support async git ops. +* [x] Support async git ops. ## Installation ```sh diff --git a/history/history.go b/history/history.go index cbd689b..c57ef96 100644 --- a/history/history.go +++ b/history/history.go @@ -99,10 +99,10 @@ func init() { } // I pronounce it as [gɪt͡ʃ]. +// gitsh is async-safe, therefore all other git-related functions in this module are too. func gitsh(args ...string) (out bytes.Buffer, err error) { fmt.Printf("$ %v\n", args) cmd := exec.Command(gitpath, args...) - cmd.Dir = util.WikiDir b, err := cmd.CombinedOutput() diff --git a/history/operations.go b/history/operations.go index fecee81..149e795 100644 --- a/history/operations.go +++ b/history/operations.go @@ -4,10 +4,14 @@ package history import ( "fmt" + "sync" "github.com/bouncepaw/mycorrhiza/util" ) +// gitMutex is used for blocking git operations to avoid clashes. +var gitMutex = sync.Mutex{} + // OpType is the type a history operation has. Callers shall set appropriate optypes when creating history operations. type OpType int @@ -31,6 +35,7 @@ type HistoryOp struct { // Operation is a constructor of a history operation. func Operation(opType OpType) *HistoryOp { + gitMutex.Lock() hop := &HistoryOp{ Errs: []error{}, opType: opType, @@ -75,6 +80,7 @@ func (hop *HistoryOp) Apply() *HistoryOp { "--author='"+hop.name+" <"+hop.email+">'", "--message="+hop.userMsg, ) + gitMutex.Unlock() return hop } diff --git a/metarrhiza b/metarrhiza index ecaa76f..2c0e431 160000 --- a/metarrhiza +++ b/metarrhiza @@ -1 +1 @@ -Subproject commit ecaa76f841afcb3514b7061eb6708092bc17ee08 +Subproject commit 2c0e43199ed28f7022a38463a0eec3af3ecb03c9