OTA测试成功
This commit is contained in:
parent
633ae66e18
commit
a373ac8a2f
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Reference in New Issue