镜像自地址
https://github.com/tuna/tunasync.git
已同步 2025-12-07 23:16:47 +00:00
@@ -106,6 +106,34 @@ exit 0
|
||||
})
|
||||
|
||||
})
|
||||
Convey("If the rsync program fails", t, func() {
|
||||
tmpDir, err := ioutil.TempDir("", "tunasync")
|
||||
defer os.RemoveAll(tmpDir)
|
||||
So(err, ShouldBeNil)
|
||||
tmpFile := filepath.Join(tmpDir, "log_file")
|
||||
|
||||
Convey("in the rsyncProvider", func() {
|
||||
|
||||
c := rsyncConfig{
|
||||
name: "tuna",
|
||||
upstreamURL: "rsync://rsync.tuna.moe/tuna/",
|
||||
workingDir: tmpDir,
|
||||
logDir: tmpDir,
|
||||
logFile: tmpFile,
|
||||
extraOptions: []string{"--somethine-invalid"},
|
||||
interval: 600 * time.Second,
|
||||
}
|
||||
|
||||
provider, err := newRsyncProvider(c)
|
||||
So(err, ShouldBeNil)
|
||||
|
||||
err = provider.Run()
|
||||
So(err, ShouldNotBeNil)
|
||||
loggedContent, err := ioutil.ReadFile(provider.LogFile())
|
||||
So(err, ShouldBeNil)
|
||||
So(string(loggedContent), ShouldContainSubstring, "Syntax or usage error")
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
func TestRsyncProviderWithAuthentication(t *testing.T) {
|
||||
@@ -556,4 +584,34 @@ exit 0
|
||||
// fmt.Println(string(loggedContent))
|
||||
})
|
||||
})
|
||||
|
||||
Convey("If the rsync program fails", t, func(ctx C) {
|
||||
tmpDir, err := ioutil.TempDir("", "tunasync")
|
||||
defer os.RemoveAll(tmpDir)
|
||||
So(err, ShouldBeNil)
|
||||
tmpFile := filepath.Join(tmpDir, "log_file")
|
||||
|
||||
Convey("in the twoStageRsyncProvider", func() {
|
||||
|
||||
c := twoStageRsyncConfig{
|
||||
name: "tuna-two-stage-rsync",
|
||||
upstreamURL: "rsync://0.0.0.1/",
|
||||
stage1Profile: "debian",
|
||||
workingDir: tmpDir,
|
||||
logDir: tmpDir,
|
||||
logFile: tmpFile,
|
||||
excludeFile: tmpFile,
|
||||
}
|
||||
|
||||
provider, err := newTwoStageRsyncProvider(c)
|
||||
So(err, ShouldBeNil)
|
||||
|
||||
err = provider.Run()
|
||||
So(err, ShouldNotBeNil)
|
||||
loggedContent, err := ioutil.ReadFile(provider.LogFile())
|
||||
So(err, ShouldBeNil)
|
||||
So(string(loggedContent), ShouldContainSubstring, "Error in socket I/O")
|
||||
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
@@ -110,6 +110,13 @@ func (p *rsyncProvider) Run() error {
|
||||
return err
|
||||
}
|
||||
if err := p.Wait(); err != nil {
|
||||
code, msg := internal.TranslateRsyncErrorCode(err)
|
||||
if code != 0 {
|
||||
logger.Debug("Rsync exitcode %d (%s)", code, msg)
|
||||
if p.logFileFd != nil {
|
||||
p.logFileFd.WriteString(msg + "\n")
|
||||
}
|
||||
}
|
||||
return err
|
||||
}
|
||||
p.dataSize = internal.ExtractSizeFromRsyncLog(p.LogFile())
|
||||
|
||||
@@ -168,6 +168,13 @@ func (p *twoStageRsyncProvider) Run() error {
|
||||
err = p.Wait()
|
||||
p.Lock()
|
||||
if err != nil {
|
||||
code, msg := internal.TranslateRsyncErrorCode(err)
|
||||
if code != 0 {
|
||||
logger.Debug("Rsync exitcode %d (%s)", code, msg)
|
||||
if p.logFileFd != nil {
|
||||
p.logFileFd.WriteString(msg + "\n")
|
||||
}
|
||||
}
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
在新工单中引用
屏蔽一个用户