From f9cad3ffe314106fb84171e6c78ee40fc4912b4c Mon Sep 17 00:00:00 2001 From: lewis <747342561@qq.com> Date: Tue, 17 Aug 2021 10:05:17 +0800 Subject: [PATCH 1/2] unified active-mail format --- options/locale/locale_zh-CN.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/options/locale/locale_zh-CN.ini b/options/locale/locale_zh-CN.ini index 5ac54f6c8..9dd2d254b 100755 --- a/options/locale/locale_zh-CN.ini +++ b/options/locale/locale_zh-CN.ini @@ -2435,7 +2435,7 @@ future=将来 1y=1年 seconds=%d 秒 minutes=%d 分钟 -hours=%d 小时 +hours=%d hours days=%d 天 weeks=%d 周 months=%d 个月 From 64ee8e30034ff0408d93643608731d98ee403f83 Mon Sep 17 00:00:00 2001 From: lewis <747342561@qq.com> Date: Tue, 17 Aug 2021 15:42:52 +0800 Subject: [PATCH 2/2] fix-50 --- models/file_chunk.go | 12 +++++++++++- routers/repo/attachment.go | 17 +++++++++++++---- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/models/file_chunk.go b/models/file_chunk.go index 9f513bd34..fc2beef56 100755 --- a/models/file_chunk.go +++ b/models/file_chunk.go @@ -87,7 +87,7 @@ func InsertFileChunk(fileChunk *FileChunk) (_ *FileChunk, err error) { return fileChunk, nil } -// UpdateAttachment updates the given attachment in database +// UpdateFileChunk updates the given file_chunk in database func UpdateFileChunk(fileChunk *FileChunk) error { return updateFileChunk(x, fileChunk) } @@ -98,3 +98,13 @@ func updateFileChunk(e Engine, fileChunk *FileChunk) error { _, err := sess.Cols("is_uploaded").Update(fileChunk) return err } + +// DeleteFileChunk delete the given file_chunk in database +func DeleteFileChunk(fileChunk *FileChunk) error { + return deleteFileChunk(x, fileChunk) +} + +func deleteFileChunk(e Engine, fileChunk *FileChunk) error { + _, err := e.ID(fileChunk.ID).Delete(fileChunk) + return err +} diff --git a/routers/repo/attachment.go b/routers/repo/attachment.go index fea7a3384..49c72b1c3 100755 --- a/routers/repo/attachment.go +++ b/routers/repo/attachment.go @@ -483,16 +483,25 @@ func GetSuccessChunks(ctx *context.Context) { if typeCloudBrain == models.TypeCloudBrainOne { chunks, err = storage.GetPartInfos(fileChunk.UUID, fileChunk.UploadID) if err != nil { - ctx.ServerError("GetPartInfos failed", err) - return + log.Error("GetPartInfos failed:%v", err.Error()) } } else { chunks, err = storage.GetObsPartInfos(fileChunk.UUID, fileChunk.UploadID) if err != nil { - ctx.ServerError("GetObsPartInfos failed", err) - return + log.Error("GetObsPartInfos failed:%v", err.Error()) } } + + if err != nil { + models.DeleteFileChunk(fileChunk) + ctx.JSON(200, map[string]string{ + "uuid": "", + "uploaded": "0", + "uploadID": "", + "chunks": "", + }) + return + } } var attachID int64