|
@@ -1,6 +1,7 @@
|
|
package otaUpgrade
|
|
package otaUpgrade
|
|
|
|
|
|
import (
|
|
import (
|
|
|
|
+ "fmt"
|
|
"github.com/gogf/gf/database/gredis"
|
|
"github.com/gogf/gf/database/gredis"
|
|
)
|
|
)
|
|
|
|
|
|
@@ -11,7 +12,7 @@ const (
|
|
)
|
|
)
|
|
|
|
|
|
type File struct {
|
|
type File struct {
|
|
- FileId string
|
|
|
|
|
|
+ FileId int
|
|
FileData []byte
|
|
FileData []byte
|
|
}
|
|
}
|
|
|
|
|
|
@@ -36,8 +37,8 @@ func NewOtaManager(host string, port, db int) *OtaManager {
|
|
return mgr
|
|
return mgr
|
|
}
|
|
}
|
|
|
|
|
|
-func (mgr *OtaManager) SavaFile(id string, fileData []byte) error {
|
|
|
|
- key := FileKeyPrefix + id
|
|
|
|
|
|
+func (mgr *OtaManager) SavaFile(id int, fileData []byte) error {
|
|
|
|
+ key := fmt.Sprintf("%s%d", FileKeyPrefix, id)
|
|
file := new(File)
|
|
file := new(File)
|
|
file.FileId = id
|
|
file.FileId = id
|
|
file.FileData = fileData
|
|
file.FileData = fileData
|
|
@@ -52,8 +53,8 @@ func (mgr *OtaManager) SavaFile(id string, fileData []byte) error {
|
|
return nil
|
|
return nil
|
|
}
|
|
}
|
|
|
|
|
|
-func (mgr *OtaManager) GetFile(id string) (*File, error) {
|
|
|
|
- key := FileKeyPrefix + id
|
|
|
|
|
|
+func (mgr *OtaManager) GetFile(id int) (*File, error) {
|
|
|
|
+ key := fmt.Sprintf("%s%d", FileKeyPrefix, id)
|
|
file := new(File)
|
|
file := new(File)
|
|
// get status from redis
|
|
// get status from redis
|
|
result, err := mgr.redisClient.DoVar("GET", key)
|
|
result, err := mgr.redisClient.DoVar("GET", key)
|
|
@@ -67,8 +68,8 @@ func (mgr *OtaManager) GetFile(id string) (*File, error) {
|
|
return file, nil
|
|
return file, nil
|
|
}
|
|
}
|
|
|
|
|
|
-func (mgr *OtaManager) DelFile(id string) error {
|
|
|
|
- key := FileKeyPrefix + id
|
|
|
|
|
|
+func (mgr *OtaManager) DelFile(id int) error {
|
|
|
|
+ key := fmt.Sprintf("%s%d", FileKeyPrefix, id)
|
|
_, err := mgr.redisClient.Do("DEL", key)
|
|
_, err := mgr.redisClient.Do("DEL", key)
|
|
if err != nil {
|
|
if err != nil {
|
|
return err
|
|
return err
|