@@ -378,7 +378,7 @@ func GetUnDecompressAttachments() ([]*Attachment, error) { | |||||
func getUnDecompressAttachments(e Engine) ([]*Attachment, error) { | func getUnDecompressAttachments(e Engine) ([]*Attachment, error) { | ||||
attachments := make([]*Attachment, 0, 10) | 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' or name like '%.tgz')", DecompressStateInit, TypeCloudBrainOne).Find(&attachments) | |||||
} | } | ||||
func GetAllPublicAttachments() ([]*AttachmentUsername, error) { | func GetAllPublicAttachments() ([]*AttachmentUsername, error) { | ||||
@@ -13,8 +13,8 @@ const ( | |||||
DecompressTaskName = "Decompress" | 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) | task, err := tasks.NewSignature(DecompressTaskName, args) | ||||
if err != nil { | if err != nil { | ||||
log.Error("NewSignature failed:", err.Error()) | log.Error("NewSignature failed:", err.Error()) | ||||
@@ -1640,22 +1640,31 @@ function showfilelist(){ | |||||
var htmlstr=""; | var htmlstr=""; | ||||
for (var i=0;i<labeltastresult.length;i++){ | for (var i=0;i<labeltastresult.length;i++){ | ||||
var fname = labeltastresult[i].pic_image_field.substring(labeltastresult[i].pic_image_field.lastIndexOf('/') + 1); | var fname = labeltastresult[i].pic_image_field.substring(labeltastresult[i].pic_image_field.lastIndexOf('/') + 1); | ||||
if(labeltastresult[i].pic_image_field.length > 70){ | |||||
var tmpIndex = labeltastresult[i].pic_image_field.indexOf("/",70); | |||||
console.log(tmpIndex) | |||||
if(tmpIndex != -1){ | |||||
fname = labeltastresult[i].pic_image_field.substring(tmpIndex + 1); | |||||
fname = fname.substring(fname.indexOf('/')+1); | |||||
} | |||||
} | |||||
var isfinished = labeltastresult[i].label_status; | var isfinished = labeltastresult[i].label_status; | ||||
if(isVerified()){ | |||||
isfinished = labeltastresult[i].verify_status - 1; | |||||
} | |||||
if(isVerified()){ | |||||
isfinished = labeltastresult[i].verify_status - 1; | |||||
} | |||||
var lablebg=" style=\"cursor:pointer\""; | var lablebg=" style=\"cursor:pointer\""; | ||||
var classStr = "style=\"color:#FF6200;background: transparent;border: 0;\""; | var classStr = "style=\"color:#FF6200;background: transparent;border: 0;\""; | ||||
var finish="未完成"; | var finish="未完成"; | ||||
if (isfinished=="0"){finish="已完成";classStr = "style=\"color:#27c24c;background: transparent;border: 0;\"";} | if (isfinished=="0"){finish="已完成";classStr = "style=\"color:#27c24c;background: transparent;border: 0;\"";} | ||||
if (i==fileindex){lablebg=" style=\"color:#fff;cursor:pointer;\"";classStr = "style=\"color:#04B3E5;background: transparent;border: 0;\"";finish="标注中"} | if (i==fileindex){lablebg=" style=\"color:#fff;cursor:pointer;\"";classStr = "style=\"color:#04B3E5;background: transparent;border: 0;\"";finish="标注中"} | ||||
if(isVerified()){ | |||||
htmlstr = htmlstr+"<tr onclick=\"clickfilelist("+i+");\""+ lablebg+"> <td width=\"70\"" +"style=\"vertical-align:middle\""+ classStr + ">"+"<button"+classStr+" type=\"button\" onclick=\"changeVerifyStatus("+i+");\" style=\"border:none;background:none\">"+finish +"</button>"+"</td><td>"+ fname+ "</td></tr>"; | |||||
}else{ | |||||
htmlstr = htmlstr+"<tr onclick=\"clickfilelist("+i+");\""+lablebg+"><td>"+fname+"</td><td width=\"110\""+"style=\"vertical-align:middle\">"+"<button onclick=\"changeStatus("+i+");\" "+ classStr +" style=\"border:none;background:none\">"+finish +"</button>"+"</td></tr>"; | |||||
} | |||||
if(isVerified()){ | |||||
htmlstr = htmlstr+"<tr onclick=\"clickfilelist("+i+");\""+ lablebg+"> <td width=\"70\"" +"style=\"vertical-align:middle\""+ classStr + ">"+"<button"+classStr+" type=\"button\" onclick=\"changeVerifyStatus("+i+");\" style=\"border:none;background:none\">"+finish +"</button>"+"</td><td>"+ fname+ "</td></tr>"; | |||||
}else{ | |||||
htmlstr = htmlstr+"<tr onclick=\"clickfilelist("+i+");\""+lablebg+"><td>"+fname+"</td><td width=\"110\""+"style=\"vertical-align:middle\">"+"<button onclick=\"changeStatus("+i+");\" "+ classStr +" style=\"border:none;background:none\">"+finish +"</button>"+"</td></tr>"; | |||||
} | |||||
}; | |||||
} | |||||
document.getElementById("filelist").innerHTML=htmlstr; | document.getElementById("filelist").innerHTML=htmlstr; | ||||
} | } | ||||
@@ -318,7 +318,7 @@ function label_task_create(task_name, relate_task_id, taskType,assign_user_id,la | |||||
success:function(res){ | success:function(res){ | ||||
console.log(res); | console.log(res); | ||||
if(res.code == 0){ | if(res.code == 0){ | ||||
alert("人工校验任务创建成功!"); | |||||
alert("人工标注任务创建成功!"); | |||||
createsucced = true; | createsucced = true; | ||||
} | } | ||||
else{ | else{ | ||||
@@ -384,9 +384,9 @@ func AddAttachment(ctx *context.Context) { | |||||
} | } | ||||
if attachment.DatasetID != 0 { | if attachment.DatasetID != 0 { | ||||
if strings.HasSuffix(attachment.Name, ".zip") { | |||||
if isCanDecompress(attachment.Name) { | |||||
if typeCloudBrain == models.TypeCloudBrainOne { | if typeCloudBrain == models.TypeCloudBrainOne { | ||||
err = worker.SendDecompressTask(contexExt.Background(), uuid) | |||||
err = worker.SendDecompressTask(contexExt.Background(), uuid, attachment.Name) | |||||
if err != nil { | if err != nil { | ||||
log.Error("SendDecompressTask(%s) failed:%s", uuid, err.Error()) | log.Error("SendDecompressTask(%s) failed:%s", uuid, err.Error()) | ||||
} else { | } 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") || strings.HasSuffix(name, ".tgz") { | |||||
return true | |||||
} | |||||
return false | |||||
} | |||||
func UpdateAttachmentDecompressState(ctx *context.Context) { | func UpdateAttachmentDecompressState(ctx *context.Context) { | ||||
uuid := ctx.Query("uuid") | uuid := ctx.Query("uuid") | ||||
result := ctx.Query("result") | result := ctx.Query("result") | ||||
@@ -766,9 +773,9 @@ func CompleteMultipart(ctx *context.Context) { | |||||
} | } | ||||
if attachment.DatasetID != 0 { | if attachment.DatasetID != 0 { | ||||
if strings.HasSuffix(attachment.Name, ".zip") { | |||||
if isCanDecompress(attachment.Name) { | |||||
if typeCloudBrain == models.TypeCloudBrainOne { | if typeCloudBrain == models.TypeCloudBrainOne { | ||||
err = worker.SendDecompressTask(contexExt.Background(), uuid) | |||||
err = worker.SendDecompressTask(contexExt.Background(), uuid, attachment.Name) | |||||
if err != nil { | if err != nil { | ||||
log.Error("SendDecompressTask(%s) failed:%s", uuid, err.Error()) | log.Error("SendDecompressTask(%s) failed:%s", uuid, err.Error()) | ||||
} else { | } else { | ||||
@@ -838,7 +845,7 @@ func HandleUnDecompressAttachment() { | |||||
} | } | ||||
for _, attach := range attachs { | for _, attach := range attachs { | ||||
err = worker.SendDecompressTask(contexExt.Background(), attach.UUID) | |||||
err = worker.SendDecompressTask(contexExt.Background(), attach.UUID, attach.Name) | |||||
if err != nil { | if err != nil { | ||||
log.Error("SendDecompressTask(%s) failed:%s", attach.UUID, err.Error()) | log.Error("SendDecompressTask(%s) failed:%s", attach.UUID, err.Error()) | ||||
} else { | } else { | ||||
@@ -39,7 +39,8 @@ func DeleteAllUnzipFile(attachment *models.Attachment, parentDir string) { | |||||
uuid := attachment.UUID | uuid := attachment.UUID | ||||
dirArray := strings.Split(parentDir, "/") | dirArray := strings.Split(parentDir, "/") | ||||
if !strings.HasSuffix(attachment.Name, ".zip") { | |||||
//if !strings.HasSuffix(attachment.Name, ".zip") { | |||||
if !isCanDecompress(attachment.Name) { | |||||
log.Error("The file is not zip file, can not query the dir") | log.Error("The file is not zip file, can not query the dir") | ||||
return | return | ||||
} else if attachment.DecompressState != models.DecompressStateDone { | } else if attachment.DecompressState != models.DecompressStateDone { | ||||
@@ -69,7 +70,7 @@ func DeleteAllUnzipFile(attachment *models.Attachment, parentDir string) { | |||||
log.Info("fileName=" + fileInfo.FileName) | log.Info("fileName=" + fileInfo.FileName) | ||||
log.Info("parentDir=" + fileInfo.ParenDir) | log.Info("parentDir=" + fileInfo.ParenDir) | ||||
if fileInfo.IsDir { | if fileInfo.IsDir { | ||||
DeleteAllUnzipFile(attachment, fileInfo.FileName) | |||||
DeleteAllUnzipFile(attachment, fileInfo.ParenDir) | |||||
} else { | } else { | ||||
absolutepath := path.Join(attachment.RelativePath()+attachment.UUID, fileInfo.ParenDir) | absolutepath := path.Join(attachment.RelativePath()+attachment.UUID, fileInfo.ParenDir) | ||||
log.Info("absolutepath=" + absolutepath) | log.Info("absolutepath=" + absolutepath) | ||||
@@ -127,7 +128,8 @@ func DirIndex(ctx *context.Context) { | |||||
return | return | ||||
} | } | ||||
if !strings.HasSuffix(attachment.Name, ".zip") { | |||||
//if !strings.HasSuffix(attachment.Name, ".zip") { | |||||
if !isCanDecompress(attachment.Name) { | |||||
log.Error("The file is not zip file, can not query the dir") | log.Error("The file is not zip file, can not query the dir") | ||||
ctx.ServerError("The file is not zip file, can not query the dir", errors.New("The file is not zip file, can not query the dir")) | ctx.ServerError("The file is not zip file, can not query the dir", errors.New("The file is not zip file, can not query the dir")) | ||||
return | return | ||||