1
0
镜像自地址 https://github.com/tuna/tunasync.git 已同步 2025-12-07 23:16:47 +00:00

Merge pull request #97 from ziqin/master

Refine: remove outer `provider`s which shadow the embedded `provider`s provided by `emptyHook`
这个提交包含在:
Yuxiang Zhang
2019-08-02 09:27:04 +08:00
提交者 GitHub
当前提交 3872c41607
共有 9 个文件被更改,包括 41 次插入34 次删除

查看文件

@@ -40,14 +40,14 @@ Pre-built binary for Linux x86_64 is available at [Github releases](https://gith
# Job Run Process
PreSyncing Syncing Success
+-----------+ +-----------+ +-------------+ +--------------+
| pre-job +--+->| job run +--->| post-exec +-+-->| post-success |
+-----------+ ^ +-----------+ +-------------+ | +--------------+
| |
| +-----------------+ | Failed
+------+ post-fail |<---------+
+-----------------+
PreSyncing Syncing Success
+-----------+ +----------+ +-----------+ +-------------+ +--------------+
| pre-job +--+->| pre-exec +--->| job run +--->| post-exec +-+-->| post-success |
+-----------+ ^ +----------+ +-----------+ +-------------+ | +--------------+
| |
| +-----------------+ | Failed
+----------------+ post-fail |<---------------+
+-----------------+
```

查看文件

@@ -109,7 +109,7 @@ func TestHTTPServer(t *testing.T) {
So(res[_errorKey], ShouldEqual, "invalid workerID "+invalidWorker)
})
Convey("flush disabled jobs", func(ctx C) {
Convey("flush disabled jobs", func(ctx C) {
req, err := http.NewRequest("DELETE", baseURL+"/jobs/disabled", nil)
So(err, ShouldBeNil)
clt := &http.Client{}

查看文件

@@ -17,7 +17,6 @@ import (
type cgroupHook struct {
emptyHook
provider mirrorProvider
basePath string
baseGroup string
created bool
@@ -36,7 +35,9 @@ func newCgroupHook(p mirrorProvider, basePath, baseGroup, subsystem, memLimit st
subsystem = "cpu"
}
return &cgroupHook{
provider: p,
emptyHook: emptyHook{
provider: p,
},
basePath: basePath,
baseGroup: baseGroup,
subsystem: subsystem,

查看文件

@@ -7,10 +7,9 @@ import (
type dockerHook struct {
emptyHook
provider mirrorProvider
image string
volumes []string
options []string
image string
volumes []string
options []string
}
func newDockerHook(p mirrorProvider, gCfg dockerConfig, mCfg mirrorConfig) *dockerHook {
@@ -23,10 +22,12 @@ func newDockerHook(p mirrorProvider, gCfg dockerConfig, mCfg mirrorConfig) *dock
options = append(options, mCfg.DockerOptions...)
return &dockerHook{
provider: p,
image: mCfg.DockerImage,
volumes: volumes,
options: options,
emptyHook: emptyHook{
provider: p,
},
image: mCfg.DockerImage,
volumes: volumes,
options: options,
}
}

查看文件

@@ -55,8 +55,10 @@ sleep 10
So(err, ShouldBeNil)
d := &dockerHook{
provider: provider,
image: "alpine",
emptyHook: emptyHook{
provider: provider,
},
image: "alpine",
volumes: []string{
fmt.Sprintf("%s:%s", cmdScript, "/bin/cmd.sh"),
},

查看文件

@@ -18,7 +18,6 @@ const (
type execPostHook struct {
emptyHook
provider mirrorProvider
// exec on success or on failure
execOn uint8
@@ -37,9 +36,11 @@ func newExecPostHook(provider mirrorProvider, execOn uint8, command string) (*ex
}
return &execPostHook{
provider: provider,
execOn: execOn,
command: cmd,
emptyHook: emptyHook{
provider: provider,
},
execOn: execOn,
command: cmd,
}, nil
}

查看文件

@@ -14,12 +14,13 @@ import (
type logLimiter struct {
emptyHook
provider mirrorProvider
}
func newLogLimiter(provider mirrorProvider) *logLimiter {
return &logLimiter{
provider: provider,
emptyHook: emptyHook{
provider: provider,
},
}
}

查看文件

@@ -141,10 +141,10 @@ func newMirrorProvider(mirror mirrorConfig, cfg *Config) mirrorProvider {
retry: mirror.Retry,
}
p, err := newRsyncProvider(rc)
p.isMaster = isMaster
if err != nil {
panic(err)
}
p.isMaster = isMaster
provider = p
case provTwoStageRsync:
rc := twoStageRsyncConfig{

查看文件

@@ -11,14 +11,15 @@ import (
type zfsHook struct {
emptyHook
provider mirrorProvider
zpool string
zpool string
}
func newZfsHook(provider mirrorProvider, zpool string) *zfsHook {
return &zfsHook{
provider: provider,
zpool: zpool,
emptyHook: emptyHook{
provider: provider,
},
zpool: zpool,
}
}
@@ -40,12 +41,12 @@ func (z *zfsHook) printHelpMessage() {
func (z *zfsHook) preJob() error {
workingDir := z.provider.WorkingDir()
if _, err := os.Stat(workingDir); os.IsNotExist(err) {
logger.Errorf("Directory %s doesn't exist", workingDir);
logger.Errorf("Directory %s doesn't exist", workingDir)
z.printHelpMessage()
return err
}
if err := sh.Command("mountpoint", "-q", workingDir).Run(); err != nil {
logger.Errorf("%s is not a mount point", workingDir);
logger.Errorf("%s is not a mount point", workingDir)
z.printHelpMessage()
return err
}