mirror of
https://github.com/tuna/tunasync.git
synced 2025-06-15 14:12:47 +00:00
format the code
This commit is contained in:
parent
7a9895350b
commit
1491b6c42b
@ -113,16 +113,16 @@ type includedMirrorConfig struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type mirrorConfig struct {
|
type mirrorConfig struct {
|
||||||
Name string `toml:"name"`
|
Name string `toml:"name"`
|
||||||
Provider providerEnum `toml:"provider"`
|
Provider providerEnum `toml:"provider"`
|
||||||
Upstream string `toml:"upstream"`
|
Upstream string `toml:"upstream"`
|
||||||
Interval int `toml:"interval"`
|
Interval int `toml:"interval"`
|
||||||
Retry int `toml:"retry"`
|
Retry int `toml:"retry"`
|
||||||
MirrorDir string `toml:"mirror_dir"`
|
MirrorDir string `toml:"mirror_dir"`
|
||||||
MirrorSubDir string `toml:"mirror_subdir"`
|
MirrorSubDir string `toml:"mirror_subdir"`
|
||||||
LogDir string `toml:"log_dir"`
|
LogDir string `toml:"log_dir"`
|
||||||
Env map[string]string `toml:"env"`
|
Env map[string]string `toml:"env"`
|
||||||
Role string `toml:"role"`
|
Role string `toml:"role"`
|
||||||
|
|
||||||
// These two options over-write the global options
|
// These two options over-write the global options
|
||||||
ExecOnSuccess []string `toml:"exec_on_success"`
|
ExecOnSuccess []string `toml:"exec_on_success"`
|
||||||
@ -152,7 +152,7 @@ type mirrorConfig struct {
|
|||||||
|
|
||||||
SnapshotPath string `toml:"snapshot_path"`
|
SnapshotPath string `toml:"snapshot_path"`
|
||||||
|
|
||||||
ChildMirrors []mirrorConfig `toml:"mirrors"`
|
ChildMirrors []mirrorConfig `toml:"mirrors"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// LoadConfig loads configuration
|
// LoadConfig loads configuration
|
||||||
@ -185,7 +185,7 @@ func LoadConfig(cfgFile string) (*Config, error) {
|
|||||||
|
|
||||||
for _, m := range cfg.MirrorsConf {
|
for _, m := range cfg.MirrorsConf {
|
||||||
if err := recursiveMirrors(cfg, nil, m); err != nil {
|
if err := recursiveMirrors(cfg, nil, m); err != nil {
|
||||||
return nil, err;
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -193,22 +193,22 @@ func LoadConfig(cfgFile string) (*Config, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func recursiveMirrors(cfg *Config, parent *mirrorConfig, mirror mirrorConfig) error {
|
func recursiveMirrors(cfg *Config, parent *mirrorConfig, mirror mirrorConfig) error {
|
||||||
var curMir mirrorConfig;
|
var curMir mirrorConfig
|
||||||
if parent != nil {
|
if parent != nil {
|
||||||
curMir = *parent;
|
curMir = *parent
|
||||||
}
|
}
|
||||||
curMir.ChildMirrors = nil;
|
curMir.ChildMirrors = nil
|
||||||
if err := mergo.Merge(&curMir, mirror, mergo.WithOverride); err != nil {
|
if err := mergo.Merge(&curMir, mirror, mergo.WithOverride); err != nil {
|
||||||
return err;
|
return err
|
||||||
}
|
}
|
||||||
if mirror.ChildMirrors == nil {
|
if mirror.ChildMirrors == nil {
|
||||||
cfg.Mirrors = append(cfg.Mirrors, curMir);
|
cfg.Mirrors = append(cfg.Mirrors, curMir)
|
||||||
} else {
|
} else {
|
||||||
for _, m := range mirror.ChildMirrors {
|
for _, m := range mirror.ChildMirrors {
|
||||||
if err := recursiveMirrors(cfg, &curMir, m); err != nil {
|
if err := recursiveMirrors(cfg, &curMir, m); err != nil {
|
||||||
return err;
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil;
|
return nil
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user