diff --git a/weed/command/filer_remote_sync.go b/weed/command/filer_remote_sync.go index ccff7c5a7..c3f96668e 100644 --- a/weed/command/filer_remote_sync.go +++ b/weed/command/filer_remote_sync.go @@ -105,7 +105,6 @@ func runFilerRemoteSynchronize(cmd *Command, args []string) bool { }) } - storageName := *remoteSyncOptions.createBucketAt remoteSyncOptions.bucketsDir = "/buckets" // check buckets again remoteSyncOptions.WithFilerClient(func(filerClient filer_pb.SeaweedFilerClient) error { @@ -117,10 +116,11 @@ func runFilerRemoteSynchronize(cmd *Command, args []string) bool { return nil }) + storageName := *remoteSyncOptions.createBucketAt if storageName != "" { fmt.Printf("synchronize %s, default new bucket creation in %s ...\n", remoteSyncOptions.bucketsDir, storageName) util.RetryForever("filer.remote.sync buckets "+storageName, func() error { - return followBucketUpdatesAndUploadToRemote(&remoteSyncOptions, filerSource, storageName) + return remoteSyncOptions.followBucketUpdatesAndUploadToRemote(filerSource) }, func(err error) bool { if err != nil { glog.Errorf("synchronize %s to %s: %v", remoteSyncOptions.bucketsDir, storageName, err) diff --git a/weed/command/filer_remote_sync_buckets.go b/weed/command/filer_remote_sync_buckets.go index dee6b2e27..60a8ecbce 100644 --- a/weed/command/filer_remote_sync_buckets.go +++ b/weed/command/filer_remote_sync_buckets.go @@ -16,7 +16,7 @@ import ( "time" ) -func followBucketUpdatesAndUploadToRemote(option *RemoteSyncOptions, filerSource *source.FilerSource, storageName string) error { +func (option *RemoteSyncOptions) followBucketUpdatesAndUploadToRemote(filerSource *source.FilerSource) error { // read filer remote storage mount mappings if detectErr := option.collectRemoteStorageConf(); detectErr != nil { @@ -46,7 +46,12 @@ func (option *RemoteSyncOptions) makeBucketedEventProcessor(filerSource *source. if !entry.IsDirectory { return nil } - client, err := option.findRemoteStorageClient(entry.Name) + remoteConf, found := option.remoteConfs[*option.createBucketAt] + if !found { + return fmt.Errorf("un-configured remote storage %s", *option.createBucketAt) + } + + client, err := remote_storage.GetRemoteStorage(remoteConf) if err != nil { return err }