From a18ff066632f9f7785155fcca7ef7cf8b147dcce Mon Sep 17 00:00:00 2001 From: bouncepaw Date: Mon, 2 Nov 2020 00:09:41 +0500 Subject: [PATCH] Fix the bug with different mime-types of uploaded binary parts --- history/history.go | 2 +- history/operations.go | 4 +++- hypha.go | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/history/history.go b/history/history.go index 4a4bf9e..e1c747b 100644 --- a/history/history.go +++ b/history/history.go @@ -125,6 +125,6 @@ func unixTimestampAsTime(ts string) *time.Time { // Rename renames from `from` to `to` using `git mv`. func Rename(from, to string) error { log.Println(util.ShorterPath(from), util.ShorterPath(to)) - _, err := gitsh("mv", from, to) + _, err := gitsh("mv", "--force", from, to) return err } diff --git a/history/operations.go b/history/operations.go index 422d245..0507483 100644 --- a/history/operations.go +++ b/history/operations.go @@ -77,7 +77,9 @@ func (hop *HistoryOp) WithFilesRenamed(pairs map[string]string) *HistoryOp { for from, to := range pairs { if from != "" { os.MkdirAll(filepath.Dir(to), 0777) - Rename(from, to) + if err := Rename(from, to); err != nil { + hop.Errs = append(hop.Errs, err) + } } } return hop diff --git a/hypha.go b/hypha.go index d0f6cbc..cc228d5 100644 --- a/hypha.go +++ b/hypha.go @@ -80,7 +80,7 @@ func (hd *HyphaData) UploadBinary(hyphaName, mime string, file multipart.File, i data, err = ioutil.ReadAll(file) ) if err != nil { - return hop.WithError(err) + return hop.WithError(err).Apply() } return hd.uploadHelp(hop, hyphaName, MimeToExtension(mime), &hd.binaryPath, isOld, data)