OTA测试成功
This commit is contained in:
parent
633ae66e18
commit
a373ac8a2f
|
|
@ -49,6 +49,7 @@ func CreateUpdateInfo(
|
||||||
|
|
||||||
// saveUpdateInfo 函数实现
|
// saveUpdateInfo 函数实现
|
||||||
func SaveUpdateInfo(exePath string, info UpdateInfo) error {
|
func SaveUpdateInfo(exePath string, info UpdateInfo) error {
|
||||||
|
saveDir := filepath.Join(exePath, "../")
|
||||||
// 创建一个字节缓冲区
|
// 创建一个字节缓冲区
|
||||||
var buffer bytes.Buffer
|
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 {
|
if err != nil {
|
||||||
return fmt.Errorf("error creating directory: %v", err)
|
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)
|
err = os.WriteFile(filePath, buffer.Bytes(), 0644)
|
||||||
|
|
@ -79,8 +80,9 @@ func SaveUpdateInfo(exePath string, info UpdateInfo) error {
|
||||||
|
|
||||||
// LoadUpdateInfo 函数实现
|
// LoadUpdateInfo 函数实现
|
||||||
func LoadUpdateInfo(exePath string) (*UpdateInfo, error) {
|
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)
|
data, err := os.ReadFile(filePath)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue