|
@@ -3,8 +3,11 @@ package worker
|
|
import (
|
|
import (
|
|
"errors"
|
|
"errors"
|
|
"fmt"
|
|
"fmt"
|
|
|
|
+ "io/ioutil"
|
|
"strings"
|
|
"strings"
|
|
"time"
|
|
"time"
|
|
|
|
+
|
|
|
|
+ "github.com/tuna/tunasync/internal"
|
|
)
|
|
)
|
|
|
|
|
|
type twoStageRsyncConfig struct {
|
|
type twoStageRsyncConfig struct {
|
|
@@ -23,6 +26,7 @@ type twoStageRsyncProvider struct {
|
|
twoStageRsyncConfig
|
|
twoStageRsyncConfig
|
|
stage1Options []string
|
|
stage1Options []string
|
|
stage2Options []string
|
|
stage2Options []string
|
|
|
|
+ dataSize string
|
|
}
|
|
}
|
|
|
|
|
|
var rsyncStage1Profiles = map[string]([]string){
|
|
var rsyncStage1Profiles = map[string]([]string){
|
|
@@ -78,6 +82,10 @@ func (p *twoStageRsyncProvider) Upstream() string {
|
|
return p.upstreamURL
|
|
return p.upstreamURL
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+func (p *twoStageRsyncProvider) DataSize() string {
|
|
|
|
+ return p.dataSize
|
|
|
|
+}
|
|
|
|
+
|
|
func (p *twoStageRsyncProvider) Options(stage int) ([]string, error) {
|
|
func (p *twoStageRsyncProvider) Options(stage int) ([]string, error) {
|
|
var options []string
|
|
var options []string
|
|
if stage == 1 {
|
|
if stage == 1 {
|
|
@@ -123,6 +131,7 @@ func (p *twoStageRsyncProvider) Run() error {
|
|
env["RSYNC_PASSWORD"] = p.password
|
|
env["RSYNC_PASSWORD"] = p.password
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ p.dataSize = ""
|
|
stages := []int{1, 2}
|
|
stages := []int{1, 2}
|
|
for _, stage := range stages {
|
|
for _, stage := range stages {
|
|
command := []string{p.rsyncCmd}
|
|
command := []string{p.rsyncCmd}
|
|
@@ -151,5 +160,8 @@ func (p *twoStageRsyncProvider) Run() error {
|
|
return err
|
|
return err
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ if logContent, err := ioutil.ReadFile(p.LogFile()); err == nil {
|
|
|
|
+ p.dataSize = internal.ExtractSizeFromRsyncLog(logContent)
|
|
|
|
+ }
|
|
return nil
|
|
return nil
|
|
}
|
|
}
|