mirror of
https://github.com/tuna/tunasync.git
synced 2025-04-21 04:42:46 +00:00
Eliminate duplicate mirrorProvider in Hooks
This commit is contained in:
parent
8408236646
commit
06fce98c00
@ -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{
|
||||
emptyHook: emptyHook{
|
||||
provider: p,
|
||||
},
|
||||
basePath: basePath,
|
||||
baseGroup: baseGroup,
|
||||
subsystem: subsystem,
|
||||
|
@ -7,7 +7,6 @@ import (
|
||||
|
||||
type dockerHook struct {
|
||||
emptyHook
|
||||
provider mirrorProvider
|
||||
image string
|
||||
volumes []string
|
||||
options []string
|
||||
@ -23,7 +22,9 @@ func newDockerHook(p mirrorProvider, gCfg dockerConfig, mCfg mirrorConfig) *dock
|
||||
options = append(options, mCfg.DockerOptions...)
|
||||
|
||||
return &dockerHook{
|
||||
emptyHook: emptyHook{
|
||||
provider: p,
|
||||
},
|
||||
image: mCfg.DockerImage,
|
||||
volumes: volumes,
|
||||
options: options,
|
||||
|
@ -18,7 +18,6 @@ const (
|
||||
|
||||
type execPostHook struct {
|
||||
emptyHook
|
||||
provider mirrorProvider
|
||||
|
||||
// exec on success or on failure
|
||||
execOn uint8
|
||||
@ -37,7 +36,9 @@ func newExecPostHook(provider mirrorProvider, execOn uint8, command string) (*ex
|
||||
}
|
||||
|
||||
return &execPostHook{
|
||||
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{
|
||||
emptyHook: emptyHook{
|
||||
provider: provider,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -11,13 +11,14 @@ import (
|
||||
|
||||
type zfsHook struct {
|
||||
emptyHook
|
||||
provider mirrorProvider
|
||||
zpool string
|
||||
}
|
||||
|
||||
func newZfsHook(provider mirrorProvider, zpool string) *zfsHook {
|
||||
return &zfsHook{
|
||||
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
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user