镜像自地址
https://github.com/tuna/tunasync.git
已同步 2025-12-06 14:36:47 +00:00
feat(worker): added global exec_on_success and exec_on_failure options
if `exec_on_success` is set on mirror-level config, it overrides the global option; if on mirror level, extra hook cmd is needed, use `exec_on_success_extra` option
这个提交包含在:
@@ -169,24 +169,35 @@ func newMirrorProvider(mirror mirrorConfig, cfg *Config) mirrorProvider {
|
||||
)
|
||||
}
|
||||
|
||||
addHookFromCmdList := func(cmdList []string, execOn uint8) {
|
||||
if execOn != execOnSuccess && execOn != execOnFailure {
|
||||
panic("Invalid option for exec-on")
|
||||
}
|
||||
for _, cmd := range cmdList {
|
||||
h, err := newExecPostHook(provider, execOn, cmd)
|
||||
if err != nil {
|
||||
logger.Errorf("Error initializing mirror %s: %s", mirror.Name, err.Error())
|
||||
panic(err)
|
||||
}
|
||||
provider.AddHook(h)
|
||||
}
|
||||
}
|
||||
|
||||
// ExecOnSuccess hook
|
||||
if mirror.ExecOnSuccess != "" {
|
||||
h, err := newExecPostHook(provider, execOnSuccess, mirror.ExecOnSuccess)
|
||||
if err != nil {
|
||||
logger.Errorf("Error initializing mirror %s: %s", mirror.Name, err.Error())
|
||||
panic(err)
|
||||
}
|
||||
provider.AddHook(h)
|
||||
if len(mirror.ExecOnSuccess) > 0 {
|
||||
addHookFromCmdList(mirror.ExecOnSuccess, execOnSuccess)
|
||||
} else {
|
||||
addHookFromCmdList(cfg.Global.ExecOnSuccess, execOnSuccess)
|
||||
}
|
||||
addHookFromCmdList(mirror.ExecOnSuccessExtra, execOnSuccess)
|
||||
|
||||
// ExecOnFailure hook
|
||||
if mirror.ExecOnFailure != "" {
|
||||
h, err := newExecPostHook(provider, execOnFailure, mirror.ExecOnFailure)
|
||||
if err != nil {
|
||||
logger.Errorf("Error initializing mirror %s: %s", mirror.Name, err.Error())
|
||||
panic(err)
|
||||
}
|
||||
provider.AddHook(h)
|
||||
if len(mirror.ExecOnFailure) > 0 {
|
||||
addHookFromCmdList(mirror.ExecOnFailure, execOnFailure)
|
||||
} else {
|
||||
addHookFromCmdList(cfg.Global.ExecOnFailure, execOnFailure)
|
||||
}
|
||||
addHookFromCmdList(mirror.ExecOnFailureExtra, execOnFailure)
|
||||
|
||||
return provider
|
||||
}
|
||||
|
||||
在新工单中引用
屏蔽一个用户