diff --git a/sync/driver_pull_client_sync.go b/sync/driver_pull_client_sync.go index a1fbc540..2309f182 100644 --- a/sync/driver_pull_client_sync.go +++ b/sync/driver_pull_client_sync.go @@ -15,6 +15,12 @@ type driverPullClientSync struct { driver driver.Driver } +func newDriverPullClientSync(ds diskSync) driverPullClientSync { + return driverPullClientSync{ + diskSync: ds, + } +} + func (s *driverPullClientSync) start() error { return s.driver.Connect() } diff --git a/sync/driver_push_client_sync.go b/sync/driver_push_client_sync.go index 645ea6cc..f5d4d3b4 100644 --- a/sync/driver_push_client_sync.go +++ b/sync/driver_push_client_sync.go @@ -20,6 +20,13 @@ type driverPushClientSync struct { files sync.Map } +func newDriverPushClientSync(ds diskSync, basePath string) driverPushClientSync { + return driverPushClientSync{ + diskSync: ds, + basePath: basePath, + } +} + func (s *driverPushClientSync) start() error { if err := s.initFileInfo(); err != nil { return err diff --git a/sync/minio_pull_client_sync.go b/sync/minio_pull_client_sync.go index e136dd51..2d36a3bc 100644 --- a/sync/minio_pull_client_sync.go +++ b/sync/minio_pull_client_sync.go @@ -38,13 +38,11 @@ func NewMinIOPullClientSync(opt Option) (Sync, error) { } s := &minIOPullClientSync{ - driverPullClientSync: driverPullClientSync{ - diskSync: *ds, - }, - endpoint: source.Addr(), - bucketName: source.RemotePath(), - secure: source.Secure(), - currentUser: users[0], + driverPullClientSync: newDriverPullClientSync(*ds), + endpoint: source.Addr(), + bucketName: source.RemotePath(), + secure: source.Secure(), + currentUser: users[0], } s.driver = minio.NewMinIODriver(s.endpoint, s.bucketName, s.secure, s.currentUser.UserName(), s.currentUser.Password(), true, r, maxTranRate, logger) diff --git a/sync/minio_push_client_sync.go b/sync/minio_push_client_sync.go index d6f450f1..65baf8c0 100644 --- a/sync/minio_push_client_sync.go +++ b/sync/minio_push_client_sync.go @@ -38,14 +38,11 @@ func NewMinIOPushClientSync(opt Option) (Sync, error) { } s := &minIOPushClientSync{ - driverPushClientSync: driverPushClientSync{ - diskSync: *ds, - basePath: "", - }, - endpoint: dest.Addr(), - bucketName: dest.RemotePath(), - secure: dest.Secure(), - currentUser: users[0], + driverPushClientSync: newDriverPushClientSync(*ds, ""), + endpoint: dest.Addr(), + bucketName: dest.RemotePath(), + secure: dest.Secure(), + currentUser: users[0], } s.driver = minio.NewMinIODriver(s.endpoint, s.bucketName, s.secure, s.currentUser.UserName(), s.currentUser.Password(), true, r, maxTranRate, logger) diff --git a/sync/sftp_pull_client_sync.go b/sync/sftp_pull_client_sync.go index 15212490..ff4cf143 100644 --- a/sync/sftp_pull_client_sync.go +++ b/sync/sftp_pull_client_sync.go @@ -29,10 +29,8 @@ func NewSftpPullClientSync(opt Option) (Sync, error) { } s := &sftpPullClientSync{ - driverPullClientSync: driverPullClientSync{ - diskSync: *ds, - }, - remoteAddr: source.Addr(), + driverPullClientSync: newDriverPullClientSync(*ds), + remoteAddr: source.Addr(), } s.driver = sftp.NewSFTPDriver(s.remoteAddr, source.SSHConfig(), true, r, maxTranRate, logger) diff --git a/sync/sftp_push_client_sync.go b/sync/sftp_push_client_sync.go index 091dbac9..9446cf76 100644 --- a/sync/sftp_push_client_sync.go +++ b/sync/sftp_push_client_sync.go @@ -29,11 +29,8 @@ func NewSftpPushClientSync(opt Option) (Sync, error) { } s := &sftpPushClientSync{ - driverPushClientSync: driverPushClientSync{ - diskSync: *ds, - basePath: dest.RemotePath(), - }, - remoteAddr: dest.Addr(), + driverPushClientSync: newDriverPushClientSync(*ds, dest.RemotePath()), + remoteAddr: dest.Addr(), } s.driver = sftp.NewSFTPDriver(s.remoteAddr, dest.SSHConfig(), true, r, maxTranRate, logger)