From a373ac8a2f82cee12e66f6d3dc2a50fea34f4546 Mon Sep 17 00:00:00 2001 From: "qcqcqc@wsl" <1220204124@zust.edu.cn> Date: Wed, 23 Apr 2025 20:10:00 +0800 Subject: [PATCH] =?UTF-8?q?OTA=E6=B5=8B=E8=AF=95=E6=88=90=E5=8A=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- version/pkg/handler/handler.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/version/pkg/handler/handler.go b/version/pkg/handler/handler.go index 5c5ff1c..ce31642 100644 --- a/version/pkg/handler/handler.go +++ b/version/pkg/handler/handler.go @@ -49,6 +49,7 @@ func CreateUpdateInfo( // saveUpdateInfo 函数实现 func SaveUpdateInfo(exePath string, info UpdateInfo) error { + saveDir := filepath.Join(exePath, "../") // 创建一个字节缓冲区 var buffer bytes.Buffer @@ -60,13 +61,13 @@ func SaveUpdateInfo(exePath string, info UpdateInfo) error { } // 确保目录存在 - err = os.MkdirAll(exePath, 0755) + err = os.MkdirAll(saveDir, 0755) if err != nil { return fmt.Errorf("error creating directory: %v", err) } // 构建文件路径 - filePath := filepath.Join(exePath, constants.UpdateInfoFileName) + filePath := filepath.Join(saveDir, constants.UpdateInfoFileName) // 将二进制数据写入文件 err = os.WriteFile(filePath, buffer.Bytes(), 0644) @@ -79,8 +80,9 @@ func SaveUpdateInfo(exePath string, info UpdateInfo) error { // LoadUpdateInfo 函数实现 func LoadUpdateInfo(exePath string) (*UpdateInfo, error) { + savePath := filepath.Join(exePath, "../") // 构建文件路径 - filePath := filepath.Join(exePath, constants.UpdateInfoFileName) + filePath := filepath.Join(savePath, constants.UpdateInfoFileName) // 从文件中读取二进制数据 data, err := os.ReadFile(filePath)