Skip to content

Commit

Permalink
remove data race, fix #946
Browse files Browse the repository at this point in the history
  • Loading branch information
Slach committed Jul 4, 2024
1 parent e0b1f18 commit ab47d58
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -333,15 +333,20 @@ func LoadConfig(configLocation string) (*Config, error) {
if (cfg.General.RemoteStorage == "gcs" || cfg.General.RemoteStorage == "azblob" || cfg.General.RemoteStorage == "cos") && cfgWithoutDefault.General.UploadConcurrency == 0 {
cfg.General.UploadConcurrency = uint8(runtime.NumCPU() / 2)
}
cfg.AzureBlob.Path = strings.TrimPrefix(cfg.AzureBlob.Path, "/")
cfg.S3.Path = strings.TrimPrefix(cfg.S3.Path, "/")
cfg.GCS.Path = strings.TrimPrefix(cfg.GCS.Path, "/")
cfg.AzureBlob.Path = strings.Trim(cfg.AzureBlob.Path, "/ ")
cfg.S3.Path = strings.Trim(cfg.S3.Path, "/ ")
cfg.GCS.Path = strings.Trim(cfg.GCS.Path, "/ ")

cfg.S3.ObjectDiskPath = strings.Trim(cfg.S3.ObjectDiskPath,"/ ")
cfg.GCS.ObjectDiskPath = strings.Trim(cfg.GCS.ObjectDiskPath,"/ ")
cfg.AzureBlob.ObjectDiskPath = strings.Trim(cfg.AzureBlob.ObjectDiskPath,"/ ")

// https://github.com/Altinity/clickhouse-backup/issues/855
if cfg.ClickHouse.FreezeByPart && cfg.ClickHouse.FreezeByPartWhere != "" && !freezeByPartBeginAndRE.MatchString(cfg.ClickHouse.FreezeByPartWhere) {
cfg.ClickHouse.FreezeByPartWhere = " AND " + cfg.ClickHouse.FreezeByPartWhere
}


log.SetLevelFromString(cfg.General.LogLevel)

if err = ValidateConfig(cfg); err != nil {
Expand Down Expand Up @@ -467,17 +472,14 @@ func ValidateObjectDiskConfig(cfg *Config) error {
if cfg.S3.Path != "" && (cfg.S3.ObjectDiskPath == "" || strings.HasPrefix(cfg.S3.Path, cfg.S3.ObjectDiskPath)) {
return fmt.Errorf("data in objects disks, invalid s3->object_disk_path config section, shall be not empty and shall not be prefix for s3->path")
}
cfg.S3.ObjectDiskPath = strings.Trim(cfg.S3.ObjectDiskPath,"/")
case "gcs":
if cfg.GCS.Path != "" && (cfg.GCS.ObjectDiskPath == "" || strings.HasPrefix(cfg.GCS.Path, cfg.GCS.ObjectDiskPath)) {
return fmt.Errorf("data in objects disks, invalid gcs->object_disk_path config section, shall be not empty and shall not be prefix for gcs->path")
}
cfg.GCS.ObjectDiskPath = strings.Trim(cfg.GCS.ObjectDiskPath,"/")
case "azblob":
if cfg.AzureBlob.Path != "" && (cfg.AzureBlob.ObjectDiskPath == "" || strings.HasPrefix(cfg.AzureBlob.Path, cfg.AzureBlob.ObjectDiskPath)) {
return fmt.Errorf("data in objects disks, invalid azblob->object_disk_path config section, shall be not empty and shall not be prefix for gcs->path")
}
cfg.AzureBlob.ObjectDiskPath = strings.Trim(cfg.AzureBlob.ObjectDiskPath,"/")
}
}
return nil
Expand Down

0 comments on commit ab47d58

Please sign in to comment.