优化task make

This commit is contained in:
algotao
2025-07-25 17:25:17 +08:00
parent a2bf3c853e
commit a78c16d301
9 changed files with 27 additions and 4 deletions

1
.gitignore vendored
View File

@@ -1,2 +1,3 @@
vendor/
*.out
build/

View File

@@ -992,7 +992,7 @@ type Task struct {
TaskSha256 string `protobuf:"bytes,3,opt,name=task_sha256,json=taskSha256,proto3" json:"task_sha256,omitempty"` // 任务sha256
TaskDescription string `protobuf:"bytes,4,opt,name=task_description,json=taskDescription,proto3" json:"task_description,omitempty"` // 任务描述
TaskFileInfos []*FileInfo `protobuf:"bytes,5,rep,name=task_file_infos,json=taskFileInfos,proto3" json:"task_file_infos,omitempty"` // 文件列表
TaskBlockSize uint64 `protobuf:"varint,6,opt,name=task_block_size,json=taskBlockSize,proto3" json:"task_block_size,omitempty"` // 文件块字节大小(推荐200M
TaskBlockSize uint64 `protobuf:"varint,6,opt,name=task_block_size,json=taskBlockSize,proto3" json:"task_block_size,omitempty"` // 文件块字节大小(推荐50M
SourcePath string `protobuf:"bytes,7,opt,name=source_path,json=sourcePath,proto3" json:"source_path,omitempty"` // 任务数据源路径
TaskSize uint64 `protobuf:"varint,8,opt,name=task_size,json=taskSize,proto3" json:"task_size,omitempty"` // 任务所有文件的总大小
// 以下字段只在返回时填写,用于提供服务端的任务状态。在请求时填写会被忽略

View File

@@ -91,7 +91,7 @@ message Task {
string task_sha256 = 3; // 任务sha256
string task_description = 4; // 任务描述
repeated FileInfo task_file_infos = 5; // 文件列表
uint64 task_block_size = 6; // 文件块字节大小(推荐200M
uint64 task_block_size = 6; // 文件块字节大小(推荐50M
string source_path = 7; // 任务数据源路径
uint64 task_size = 8; // 任务所有文件的总大小

View File

@@ -62,7 +62,7 @@ func paramBatchSize(fs *flag.FlagSet) *uint {
}
func paramBlockSize(fs *flag.FlagSet) *string {
return fs.String("blocksize", "200M", "Block size to make hash. using size mode K, M, G, T")
return fs.String("blocksize", "50M", "Block size to make hash. using size mode K, M, G, T")
}
func paramClear(fs *flag.FlagSet) *bool {

View File

@@ -104,6 +104,9 @@ func doMakeHash(makeTaskParams *makeTaskParams, firstLevel bool) error {
if !fsInfo.IsDir() {
// 如果是文件,直接计算
if firstLevel {
makeTaskParams.task.SourcePath = filepath.Dir(makeTaskParams.sourcePath)
}
err = doTaskMake(makeTaskParams)
if err != nil {
return err

View File

@@ -94,7 +94,9 @@ func doTaskUpload(uploadTaskParams uploadTaskParams) error {
}
if blockRes.GetCode() != saasapi.ErrorCode_SUCC {
return fmt.Errorf("upload block error, code %d, msg %s", blockRes.GetCode(), blockRes.GetStatus())
err = fmt.Errorf("upload block error, code %d, msg %s", blockRes.GetCode(), blockRes.GetStatus())
fmt.Fprintln(os.Stderr, err)
return err
} else {
fmt.Printf("upload block success. file: %v, sha256 %v. block %v/%v, file %v/%v\n",
finfo.GetFileName(), binfo.GetBlockSha256(),

View File

@@ -0,0 +1,14 @@
FROM rta-docker.pkg.coding.net/public/docker/entre_dev:latest AS builder
ARG TARGETOS TARGETARCH APPNAME
COPY . /tmp/saasapi/
WORKDIR /tmp/saasapi/
RUN --mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,target=/go/pkg \
./make.sh
FROM rta-docker.pkg.coding.net/public/docker/alpine:latest AS product
COPY --from=builder /tmp/saasapi/build/saastool /bin/saastool

3
make.sh Executable file
View File

@@ -0,0 +1,3 @@
cd cmd/saastool
go build -o ../../build/saastool
cd ../../