Skip to content

Commit

Permalink
Add the newDriverPullClientSync and newDriverPushClientSync functions (
Browse files Browse the repository at this point in the history
  • Loading branch information
mstmdev authored Oct 6, 2023
1 parent 0aa2618 commit f61f8d2
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 24 deletions.
6 changes: 6 additions & 0 deletions sync/driver_pull_client_sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand Down
7 changes: 7 additions & 0 deletions sync/driver_push_client_sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 5 additions & 7 deletions sync/minio_pull_client_sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
13 changes: 5 additions & 8 deletions sync/minio_push_client_sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 2 additions & 4 deletions sync/sftp_pull_client_sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
7 changes: 2 additions & 5 deletions sync/sftp_push_client_sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit f61f8d2

Please sign in to comment.