LingxinMeng hai 9 meses
pai
achega
e85075042c

+ 1 - 1
aarch64/pjibot_guide/common/config/yaml/引导机器人默认配置文件-cloud-config.yaml

@@ -18,7 +18,7 @@ disk:
   used: 20000000000 # 磁盘占用阈值,单位bytes
 data-dir:
   src: /root/pjirobot/data # 需要额外采集的 data 目录
-  dest: /root/pjirobot/data.zip # 需要额外采集的 data 目录压缩之后的包
+  dest: /root/pjirobot/data.tar.gz # 需要额外采集的 data 目录压缩之后的包
   exclude: /root/pjirobot/data/cicv-data-closedloop # 采集data目录时排除的子目录
 map-buf-files:
   - /root/pjirobot/data/mapBuf/forbid_area.json

+ 1 - 1
aarch64/pjibot_guide/common/service/rosbag_upload.go

@@ -155,7 +155,7 @@ outLoop:
 		}
 
 		// 额外采集data目录
-		err = util.ZipDir(commonConfig.CloudConfig.DataDir.Src, commonConfig.CloudConfig.DataDir.Dest, commonConfig.CloudConfig.DataDir.Exclude)
+		err = util.TarGzDir(commonConfig.CloudConfig.DataDir.Src, commonConfig.CloudConfig.DataDir.Dest, commonConfig.CloudConfig.DataDir.Exclude)
 		if err != nil {
 			c_log.GlobalLogger.Error("压缩data目录失败:", err)
 		}

+ 19 - 0
common/util/u_io.go

@@ -34,6 +34,25 @@ func ZipDir(src, dest, excludeDir string) error {
 	return nil
 }
 
+func TarGzDir(src, dest, excludeDir string) error {
+	// 获取相对路径,以便用于排除目录
+	relExcludeDir, err := filepath.Rel(src, excludeDir)
+	if err != nil {
+		return err
+	}
+
+	// 构建 tar 命令
+	tarCmd := exec.Command("tar", "-czf", dest, "--exclude", relExcludeDir, "-C", src, ".")
+
+	// 运行命令并捕获输出
+	output, err := tarCmd.CombinedOutput()
+	if err != nil {
+		return fmt.Errorf("tar command failed: %v, output: %s", err, string(output))
+	}
+
+	return nil
+}
+
 func GetFileSize(filePath string) (int, error) {
 	fileInfo, err := os.Stat(filePath)
 	if err != nil {

+ 4 - 0
deploy/build-compress_data.sh

@@ -0,0 +1,4 @@
+#!/bin/bash
+
+# 监控接口
+go build -o ./deploy/exe/compress_data.exe ./tools/compress_data/main.go

+ 0 - 4
deploy/build-zip_data.sh

@@ -1,4 +0,0 @@
-#!/bin/bash
-
-# 监控接口
-go build -o ./deploy/exe/zip_data.exe ./tools/zip_data/main.go

+ 1 - 1
tools/zip_data/main.go → tools/compress_data/main.go

@@ -5,7 +5,7 @@ import "cicv-data-closedloop/common/util"
 func main() {
 	_ = util.ZipDir(
 		"/root/pjirobot/data",
-		"/root/pjirobot/data.zip",
+		"/root/pjirobot/data.tar.gz",
 		"/root/pjirobot/data/cicv-data-closedloop",
 	)
 }