Browse Source

refactor and fix strings.Split

pull/3415/head
chrislu 2 years ago
parent
commit
67814a5c79
  1. 3
      weed/command/filer_backup.go
  2. 4
      weed/command/filer_sync.go
  3. 5
      weed/command/master.go
  4. 6
      weed/command/server.go
  5. 4
      weed/command/volume.go
  6. 3
      weed/s3api/tags.go
  7. 3
      weed/shell/shell_liner.go
  8. 2
      weed/util/fullpath.go

3
weed/command/filer_backup.go

@ -8,7 +8,6 @@ import (
"github.com/seaweedfs/seaweedfs/weed/security"
"github.com/seaweedfs/seaweedfs/weed/util"
"google.golang.org/grpc"
"strings"
"time"
)
@ -87,7 +86,7 @@ func doFilerBackup(grpcDialOption grpc.DialOption, backupOption *FilerBackupOpti
sourceFiler := pb.ServerAddress(*backupOption.filer)
sourcePath := *backupOption.path
excludePaths := strings.Split(*backupOption.excludePaths, ",")
excludePaths := util.StringSplit(*backupOption.excludePaths, ",")
timeAgo := *backupOption.timeAgo
targetPath := dataSink.GetSinkToDirectory()
debug := *backupOption.debug

4
weed/command/filer_sync.go

@ -143,7 +143,7 @@ func runFilerSynchronize(cmd *Command, args []string) bool {
grpcDialOption,
filerA,
*syncOptions.aPath,
util.Split(*syncOptions.aExcludePaths, ","),
util.StringSplit(*syncOptions.aExcludePaths, ","),
*syncOptions.aProxyByFiler,
filerB,
*syncOptions.bPath,
@ -179,7 +179,7 @@ func runFilerSynchronize(cmd *Command, args []string) bool {
grpcDialOption,
filerB,
*syncOptions.bPath,
util.Split(*syncOptions.bExcludePaths, ","),
util.StringSplit(*syncOptions.bExcludePaths, ","),
*syncOptions.bProxyByFiler,
filerA,
*syncOptions.aPath,

5
weed/command/master.go

@ -113,10 +113,7 @@ func runMaster(cmd *Command, args []string) bool {
glog.Fatalf("Check Meta Folder (-mdir) Writable %s : %s", *m.metaFolder, err)
}
var masterWhiteList []string
if *m.whiteList != "" {
masterWhiteList = strings.Split(*m.whiteList, ",")
}
masterWhiteList := util.StringSplit(*m.whiteList, ",")
if *m.volumeSizeLimitMB > util.VolumeSizeLimitGB*1000 {
glog.Fatalf("volumeSizeLimitMB should be smaller than 30000")
}

6
weed/command/server.go

@ -76,8 +76,6 @@ var (
isStartingWebDav = cmdServer.Flag.Bool("webdav", false, "whether to start WebDAV gateway")
isStartingMqBroker = cmdServer.Flag.Bool("mq.broker", false, "whether to start message queue broker")
serverWhiteList []string
False = false
)
@ -248,9 +246,7 @@ func runServer(cmd *Command, args []string) bool {
}
filerOptions.defaultLevelDbDirectory = masterOptions.metaFolder
if *serverWhiteListOption != "" {
serverWhiteList = strings.Split(*serverWhiteListOption, ",")
}
serverWhiteList := util.StringSplit(*serverWhiteListOption, ",")
if *isStartingFiler {
go func() {

4
weed/command/volume.go

@ -188,9 +188,7 @@ func (v VolumeServerOptions) startVolumeServer(volumeFolders, maxVolumeCounts, v
}
// security related white list configuration
if volumeWhiteListOption != "" {
v.whiteList = strings.Split(volumeWhiteListOption, ",")
}
v.whiteList = util.StringSplit(volumeWhiteListOption, ",")
if *v.ip == "" {
*v.ip = util.DetectedHostAddress()

3
weed/s3api/tags.go

@ -3,6 +3,7 @@ package s3api
import (
"encoding/xml"
"fmt"
"github.com/seaweedfs/seaweedfs/weed/util"
"regexp"
"strings"
)
@ -43,7 +44,7 @@ func FromTags(tags map[string]string) (t *Tagging) {
func parseTagsHeader(tags string) (map[string]string, error) {
parsedTags := make(map[string]string)
for _, v := range strings.Split(tags, "&") {
for _, v := range util.StringSplit(tags, "&") {
tag := strings.Split(v, "=")
if len(tag) == 2 {
parsedTags[tag[0]] = tag[1]

3
weed/shell/shell_liner.go

@ -7,6 +7,7 @@ import (
"github.com/seaweedfs/seaweedfs/weed/pb"
"github.com/seaweedfs/seaweedfs/weed/pb/filer_pb"
"github.com/seaweedfs/seaweedfs/weed/pb/master_pb"
"github.com/seaweedfs/seaweedfs/weed/util"
"github.com/seaweedfs/seaweedfs/weed/util/grace"
"golang.org/x/exp/slices"
"io"
@ -100,7 +101,7 @@ https://cloud.seaweedfs.com/ui/%s
return
}
for _, c := range strings.Split(cmd, ";") {
for _, c := range util.StringSplit(cmd, ";") {
if processEachCmd(reg, c, commandEnv) {
return
}

2
weed/util/fullpath.go

@ -71,7 +71,7 @@ func (fp FullPath) IsUnder(other FullPath) bool {
return strings.HasPrefix(string(fp), string(other)+"/")
}
func Split(separatedValues string, sep string) []string {
func StringSplit(separatedValues string, sep string) []string {
if separatedValues == "" {
return nil
}

Loading…
Cancel
Save