diff --git a/models/attachment.go b/models/attachment.go index 4f2c8d09a..2a3bbf9c8 100755 --- a/models/attachment.go +++ b/models/attachment.go @@ -378,7 +378,7 @@ func GetUnDecompressAttachments() ([]*Attachment, error) { func getUnDecompressAttachments(e Engine) ([]*Attachment, error) { attachments := make([]*Attachment, 0, 10) - return attachments, e.Where("decompress_state = ? and dataset_id != 0 and attachment.type = ? and name like '%.zip'", DecompressStateInit, TypeCloudBrainOne).Find(&attachments) + return attachments, e.Where("decompress_state = ? and dataset_id != 0 and attachment.type = ? and (name like '%.zip' or name like '%.tar.gz')", DecompressStateInit, TypeCloudBrainOne).Find(&attachments) } func GetAllPublicAttachments() ([]*AttachmentUsername, error) { diff --git a/modules/worker/task.go b/modules/worker/task.go index 073b16b92..c2d9467dc 100755 --- a/modules/worker/task.go +++ b/modules/worker/task.go @@ -13,8 +13,8 @@ const ( DecompressTaskName = "Decompress" ) -func SendDecompressTask(ctx context.Context, uuid string) error { - args := []tasks.Arg{{Name: "uuid", Type: "string", Value: uuid}} +func SendDecompressTask(ctx context.Context, uuid string, name string) error { + args := []tasks.Arg{{Name: "uuid", Type: "string", Value: uuid}, {Name: "name", Type: "string", Value: name}} task, err := tasks.NewSignature(DecompressTaskName, args) if err != nil { log.Error("NewSignature failed:", err.Error()) diff --git a/routers/repo/attachment.go b/routers/repo/attachment.go index cfbbc73a4..1ac496c2f 100755 --- a/routers/repo/attachment.go +++ b/routers/repo/attachment.go @@ -386,7 +386,7 @@ func AddAttachment(ctx *context.Context) { if attachment.DatasetID != 0 { if strings.HasSuffix(attachment.Name, ".zip") { if typeCloudBrain == models.TypeCloudBrainOne { - err = worker.SendDecompressTask(contexExt.Background(), uuid) + err = worker.SendDecompressTask(contexExt.Background(), uuid, attachment.Name) if err != nil { log.Error("SendDecompressTask(%s) failed:%s", uuid, err.Error()) } else { @@ -406,6 +406,13 @@ func AddAttachment(ctx *context.Context) { }) } +func isCanDecompress(name string) bool { + if strings.HasSuffix(name, ".zip") || strings.HasSuffix(name, ".tar.gz") { + return true + } + return false +} + func UpdateAttachmentDecompressState(ctx *context.Context) { uuid := ctx.Query("uuid") result := ctx.Query("result") @@ -768,7 +775,7 @@ func CompleteMultipart(ctx *context.Context) { if attachment.DatasetID != 0 { if strings.HasSuffix(attachment.Name, ".zip") { if typeCloudBrain == models.TypeCloudBrainOne { - err = worker.SendDecompressTask(contexExt.Background(), uuid) + err = worker.SendDecompressTask(contexExt.Background(), uuid, attachment.Name) if err != nil { log.Error("SendDecompressTask(%s) failed:%s", uuid, err.Error()) } else { @@ -838,7 +845,7 @@ func HandleUnDecompressAttachment() { } for _, attach := range attachs { - err = worker.SendDecompressTask(contexExt.Background(), attach.UUID) + err = worker.SendDecompressTask(contexExt.Background(), attach.UUID, attach.Name) if err != nil { log.Error("SendDecompressTask(%s) failed:%s", attach.UUID, err.Error()) } else {