Skip to content

Commit

Permalink
fix:when change file encrypt datakey will panic
Browse files Browse the repository at this point in the history
  • Loading branch information
chuntaojun committed Sep 17, 2023
1 parent da7b723 commit 74ab553
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions pkg/config/location_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,22 @@ type LocationProviderConfigImpl struct {
Options map[string]interface{} `yaml:"options" json:"options"`
}

func (l LocationProviderConfigImpl) GetType() string {
func (l *LocationProviderConfigImpl) GetType() string {
return l.Type
}

func (l LocationProviderConfigImpl) GetOptions() map[string]interface{} {
func (l *LocationProviderConfigImpl) GetOptions() map[string]interface{} {
return l.Options
}

func (l LocationProviderConfigImpl) Verify() error {
func (l *LocationProviderConfigImpl) Verify() error {
if l.Type == "" {
return errors.New("type is empty")
}
return nil
}

func (l LocationProviderConfigImpl) SetDefault() {
func (l *LocationProviderConfigImpl) SetDefault() {
if len(l.Options) == 0 {
l.Options = map[string]interface{}{}
}
Expand Down
4 changes: 1 addition & 3 deletions pkg/flow/configuration/config_flow.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,8 @@ type ConfigFileFlow struct {
}

// NewConfigFileFlow 创建配置中心服务
func NewConfigFileFlow(connector configconnector.ConfigConnector,
chain configfilter.Chain,
func NewConfigFileFlow(connector configconnector.ConfigConnector, chain configfilter.Chain,
configuration config.Configuration) (*ConfigFileFlow, error) {

persistHandler, err := NewCachePersistHandler(
configuration.GetConfigFile().GetLocalCache().GetPersistDir(),
configuration.GetConfigFile().GetLocalCache().GetPersistMaxWriteRetry(),
Expand Down
3 changes: 2 additions & 1 deletion pkg/flow/configuration/local_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ package configuration
import (
"encoding/json"
"fmt"
"io/ioutil"
"os"
"path/filepath"
"time"
Expand Down Expand Up @@ -89,7 +90,7 @@ func (cph *CachePersistHandler) loadMessageFromAbsoluteFile(cacheFile string, me
var lastErr error
var retryTimes int
for retryTimes = 0; retryTimes <= maxRetry; retryTimes++ {
cacheJson, err := os.ReadFile(cacheFile)
cacheJson, err := ioutil.ReadFile(cacheFile)
if err != nil {
lastErr = model.NewSDKError(model.ErrCodeDiskError, err, "fail to read file cache")
// 文件打开失败的话,重试没有意义,直接失败
Expand Down
1 change: 1 addition & 0 deletions pkg/plugin/configconnector/config_file.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ func (c *ConfigFile) String() string {
_, _ = bf.WriteString("file_name=" + c.FileName)
_, _ = bf.WriteString("version=" + strconv.FormatUint(c.Version, 10))
_, _ = bf.WriteString("encrypt=" + strconv.FormatBool(c.Encrypted))
//nolint: errchkjson
data, _ := json.Marshal(c.Tags)
_, _ = bf.WriteString("tags=" + string(data))
return bf.String()
Expand Down

0 comments on commit 74ab553

Please sign in to comment.