diff --git a/history/operations.go b/history/operations.go
index b815c28..97e7aa7 100644
--- a/history/operations.go
+++ b/history/operations.go
@@ -59,12 +59,16 @@ func (hop *HistoryOp) gitop(args ...string) *HistoryOp {
return hop
}
-// WithError appends the `err` to the list of errors.
-func (hop *HistoryOp) WithError(err error) *HistoryOp {
+// WithErr appends the `err` to the list of errors.
+func (hop *HistoryOp) WithErr(err error) *HistoryOp {
hop.Errs = append(hop.Errs, err)
return hop
}
+func (hop *HistoryOp) WithErrAbort(err error) *HistoryOp {
+ return hop.WithErr(err).Abort()
+}
+
// WithFilesRemoved git-rm-s all passed `paths`. Paths can be rooted or not. Paths that are empty strings are ignored.
func (hop *HistoryOp) WithFilesRemoved(paths ...string) *HistoryOp {
args := []string{"rm", "--quiet", "--"}
diff --git a/shroom/delete.go b/shroom/delete.go
index f88f017..2341351 100644
--- a/shroom/delete.go
+++ b/shroom/delete.go
@@ -13,7 +13,7 @@ func DeleteHypha(u *user.User, h *hyphae.Hypha) (hop *history.HistoryOp, errtitl
hop = history.Operation(history.TypeDeleteHypha)
if err, errtitle := CanDelete(u, h); errtitle != "" {
- hop.WithError(err).Abort()
+ hop.WithErrAbort(err)
return hop, errtitle
}
diff --git a/shroom/rename.go b/shroom/rename.go
index 7689538..1f861b2 100644
--- a/shroom/rename.go
+++ b/shroom/rename.go
@@ -37,11 +37,11 @@ func RenameHypha(h *hyphae.Hypha, newHypha *hyphae.Hypha, recursive bool, u *use
hop = history.Operation(history.TypeRenameHypha)
if err, errtitle := CanRename(u, h); errtitle != "" {
- hop.WithError(err)
+ hop.WithErrAbort(err)
return hop, errtitle
}
if err, errtitle := canRenameThisToThat(h, newHypha, u); errtitle != "" {
- hop.WithError(err)
+ hop.WithErrAbort(err)
return hop, errtitle
}
diff --git a/shroom/unattach.go b/shroom/unattach.go
index 5ed5b0f..60f31e6 100644
--- a/shroom/unattach.go
+++ b/shroom/unattach.go
@@ -14,7 +14,7 @@ func UnattachHypha(u *user.User, h *hyphae.Hypha) (hop *history.HistoryOp, errti
hop = history.Operation(history.TypeUnattachHypha)
if err, errtitle := CanUnattach(u, h); errtitle != "" {
- hop.WithError(err).Abort()
+ hop.WithErrAbort(err)
return hop, errtitle
}
@@ -26,7 +26,8 @@ func UnattachHypha(u *user.User, h *hyphae.Hypha) (hop *history.HistoryOp, errti
if len(hop.Errs) > 0 {
rejectUnattachLog(h, u, "fail")
- return hop.WithError(errors.New(fmt.Sprintf("Could not unattach this hypha due to internal server errors: %v", hop.Errs))), "Error"
+ // FIXME: something may be wrong here
+ return hop.WithErrAbort(errors.New(fmt.Sprintf("Could not unattach this hypha due to internal server errors: %v", hop.Errs))), "Error"
}
if h.BinaryPath != "" {
diff --git a/shroom/upload.go b/shroom/upload.go
index 08634b2..c72ec9a 100644
--- a/shroom/upload.go
+++ b/shroom/upload.go
@@ -25,10 +25,10 @@ func UploadText(h *hyphae.Hypha, data []byte, u *user.User) (hop *history.Histor
}
if err, errtitle := CanEdit(u, h); err != nil {
- return hop.WithError(err), errtitle
+ return hop.WithErrAbort(err), errtitle
}
if len(data) == 0 {
- return hop.WithError(errors.New("No data passed")), "Empty"
+ return hop.WithErrAbort(errors.New("No data passed")), "Empty"
}
return uploadHelp(h, hop, ".myco", data, u)
@@ -41,13 +41,13 @@ func UploadBinary(h *hyphae.Hypha, mime string, file multipart.File, u *user.Use
)
if err != nil {
- return hop.WithError(err), err.Error()
+ return hop.WithErrAbort(err), err.Error()
}
if err, errtitle := CanAttach(u, h); err != nil {
- return hop.WithError(err), errtitle
+ return hop.WithErrAbort(err), errtitle
}
if len(data) == 0 {
- return hop.WithError(errors.New("No data passed")), "Empty"
+ return hop.WithErrAbort(errors.New("No data passed")), "Empty"
}
return uploadHelp(h, hop, mimetype.ToExtension(mime), data, u)
@@ -64,16 +64,16 @@ func uploadHelp(h *hyphae.Hypha, hop *history.HistoryOp, ext string, data []byte
}
if err := os.MkdirAll(filepath.Dir(fullPath), 0777); err != nil {
- return hop.WithError(err), err.Error()
+ return hop.WithErrAbort(err), err.Error()
}
if err := ioutil.WriteFile(fullPath, data, 0644); err != nil {
- return hop.WithError(err), err.Error()
+ return hop.WithErrAbort(err), err.Error()
}
if h.Exists && *originalFullPath != fullPath && *originalFullPath != "" {
if err := history.Rename(*originalFullPath, fullPath); err != nil {
- return hop.WithError(err), err.Error()
+ return hop.WithErrAbort(err), err.Error()
}
log.Println("Move", *originalFullPath, "to", fullPath)
}