Skip to content

Commit

Permalink
add missing lock
Browse files Browse the repository at this point in the history
  • Loading branch information
bachue committed Apr 26, 2024
1 parent f6130a8 commit cb42789
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions internal/configfile/config_file.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"errors"
"path/filepath"
"strings"
"sync"

"github.com/BurntSushi/toml"
"github.com/qiniu/go-sdk/v7/internal/env"
Expand All @@ -18,6 +19,7 @@ type profileConfig struct {

var (
profileConfigs map[string]*profileConfig
profileConfigsMutex sync.Mutex
ErrInvalidBucketUrl = errors.New("invalid bucket url")
)

Expand Down Expand Up @@ -79,6 +81,9 @@ func getProfile() (*profileConfig, error) {
}

func load() error {
profileConfigsMutex.Lock()
defer profileConfigsMutex.Unlock()

if profileConfigs != nil {
return nil
}
Expand Down

0 comments on commit cb42789

Please sign in to comment.