|
|
@@ -112,7 +112,7 @@ func DeleteAttachment(ctx *context.Context) { |
|
|
|
ctx.Error(403) |
|
|
|
return |
|
|
|
} |
|
|
|
err = models.DeleteAttachment(attach, true) |
|
|
|
err = models.DeleteAttachment(attach, false) |
|
|
|
if err != nil { |
|
|
|
ctx.Error(500, fmt.Sprintf("DeleteAttachment: %v", err)) |
|
|
|
return |
|
|
@@ -357,11 +357,25 @@ func GetSuccessChunks(ctx *context.Context) { |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
var attachID int64 |
|
|
|
attach, err := models.GetAttachmentByUUID(fileChunk.UUID) |
|
|
|
if err != nil { |
|
|
|
if models.IsErrAttachmentNotExist(err) { |
|
|
|
attachID = 0 |
|
|
|
} else { |
|
|
|
ctx.ServerError("GetAttachmentByUUID", err) |
|
|
|
return |
|
|
|
} |
|
|
|
} else { |
|
|
|
attachID = attach.ID |
|
|
|
} |
|
|
|
|
|
|
|
ctx.JSON(200, map[string]string{ |
|
|
|
"uuid": fileChunk.UUID, |
|
|
|
"uploaded": strconv.Itoa(fileChunk.IsUploaded), |
|
|
|
"uploadID":fileChunk.UploadID, |
|
|
|
"chunks": string(chunks), |
|
|
|
"attachID": strconv.Itoa(int(attachID)), |
|
|
|
}) |
|
|
|
|
|
|
|
} |
|
|
@@ -472,7 +486,7 @@ func CompleteMultipart(ctx *context.Context) { |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
_, err = models.InsertAttachment(&models.Attachment{ |
|
|
|
attachment, err := models.InsertAttachment(&models.Attachment{ |
|
|
|
UUID: uuid, |
|
|
|
UploaderID: ctx.User.ID, |
|
|
|
IsPrivate: true, |
|
|
@@ -486,6 +500,21 @@ func CompleteMultipart(ctx *context.Context) { |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
if attachment.DatasetID != 0 { |
|
|
|
if strings.HasSuffix(attachment.Name, ".zip") { |
|
|
|
err = worker.SendDecompressTask(contexExt.Background(), uuid) |
|
|
|
if err != nil { |
|
|
|
log.Error("SendDecompressTask(%s) failed:%s", uuid, err.Error()) |
|
|
|
} else { |
|
|
|
attachment.DecompressState = models.DecompressStateIng |
|
|
|
err = models.UpdateAttachment(attachment) |
|
|
|
if err != nil { |
|
|
|
log.Error("UpdateAttachment state(%s) failed:%s", uuid, err.Error()) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
ctx.JSON(200, map[string]string{ |
|
|
|
"result_code": "0", |
|
|
|
}) |
|
|
|