diff --git a/weed/filer/reader_at.go b/weed/filer/reader_at.go index 835d6cfc2..da7eae621 100644 --- a/weed/filer/reader_at.go +++ b/weed/filer/reader_at.go @@ -75,7 +75,7 @@ func LookupFn(filerClient filer_pb.FilerClient) LookupFileIdFunctionType { } for _, loc := range locations.Locations { - volumeServerAddress := filerClient.AdjustedUrl(loc.Url) + volumeServerAddress := filerClient.AdjustedUrl(loc) targetUrl := fmt.Sprintf("http://%s/%s", volumeServerAddress, fileId) targetUrls = append(targetUrls, targetUrl) } diff --git a/weed/filesys/wfs_deletion.go b/weed/filesys/wfs_deletion.go index 9791c8630..a245b6795 100644 --- a/weed/filesys/wfs_deletion.go +++ b/weed/filesys/wfs_deletion.go @@ -68,7 +68,7 @@ func (wfs *WFS) deleteFileIds(grpcDialOption grpc.DialOption, client filer_pb.Se } for _, loc := range locations.Locations { lr.Locations = append(lr.Locations, operation.Location{ - Url: wfs.AdjustedUrl(loc.Url), + Url: wfs.AdjustedUrl(loc), PublicUrl: loc.PublicUrl, }) } diff --git a/weed/filesys/wfs_filer_client.go b/weed/filesys/wfs_filer_client.go index 736df3588..8c30de3c5 100644 --- a/weed/filesys/wfs_filer_client.go +++ b/weed/filesys/wfs_filer_client.go @@ -26,15 +26,15 @@ func (wfs *WFS) WithFilerClient(fn func(filer_pb.SeaweedFilerClient) error) erro } -func (wfs *WFS) AdjustedUrl(hostAndPort string) string { +func (wfs *WFS) AdjustedUrl(location *filer_pb.Location) string { if !wfs.option.OutsideContainerClusterMode { - return hostAndPort + return location.Url } - commaIndex := strings.Index(hostAndPort, ":") + commaIndex := strings.Index(location.Url, ":") if commaIndex < 0 { - return hostAndPort + return location.Url } filerCommaIndex := strings.Index(wfs.option.FilerGrpcAddress, ":") - return fmt.Sprintf("%s:%s", wfs.option.FilerGrpcAddress[:filerCommaIndex], hostAndPort[commaIndex+1:]) + return fmt.Sprintf("%s:%s", wfs.option.FilerGrpcAddress[:filerCommaIndex], location.Url[commaIndex+1:]) } diff --git a/weed/filesys/wfs_write.go b/weed/filesys/wfs_write.go index fec33e4ab..e7db31203 100644 --- a/weed/filesys/wfs_write.go +++ b/weed/filesys/wfs_write.go @@ -38,8 +38,12 @@ func (wfs *WFS) saveDataAsChunk(dir string) filer.SaveDataAsChunkFunctionType { return fmt.Errorf("assign volume failure %v: %v", request, resp.Error) } - fileId, host, auth = resp.FileId, resp.Url, security.EncodedJwt(resp.Auth) - host = wfs.AdjustedUrl(host) + fileId, auth = resp.FileId, security.EncodedJwt(resp.Auth) + loc := &filer_pb.Location{ + Url: resp.Url, + PublicUrl: resp.PublicUrl, + } + host = wfs.AdjustedUrl(loc) collection, replication = resp.Collection, resp.Replication return nil diff --git a/weed/messaging/broker/broker_append.go b/weed/messaging/broker/broker_append.go index 80f107e00..8e5b56fd0 100644 --- a/weed/messaging/broker/broker_append.go +++ b/weed/messaging/broker/broker_append.go @@ -108,6 +108,6 @@ func (broker *MessageBroker) WithFilerClient(fn func(filer_pb.SeaweedFilerClient } -func (broker *MessageBroker) AdjustedUrl(hostAndPort string) string { - return hostAndPort +func (broker *MessageBroker) AdjustedUrl(location *filer_pb.Location) string { + return location.Url } diff --git a/weed/pb/filer_pb/filer_client.go b/weed/pb/filer_pb/filer_client.go index 4eacfa2e5..96a716d5b 100644 --- a/weed/pb/filer_pb/filer_client.go +++ b/weed/pb/filer_pb/filer_client.go @@ -21,7 +21,7 @@ var ( type FilerClient interface { WithFilerClient(fn func(SeaweedFilerClient) error) error - AdjustedUrl(hostAndPort string) string + AdjustedUrl(location *Location) string } func GetEntry(filerClient FilerClient, fullFilePath util.FullPath) (entry *Entry, err error) { diff --git a/weed/replication/sink/filersink/fetch_write.go b/weed/replication/sink/filersink/fetch_write.go index d33669447..98330da6b 100644 --- a/weed/replication/sink/filersink/fetch_write.go +++ b/weed/replication/sink/filersink/fetch_write.go @@ -124,6 +124,6 @@ func (fs *FilerSink) WithFilerClient(fn func(filer_pb.SeaweedFilerClient) error) }, fs.grpcAddress, fs.grpcDialOption) } -func (fs *FilerSink) AdjustedUrl(hostAndPort string) string { - return hostAndPort +func (fs *FilerSink) AdjustedUrl(location *filer_pb.Location) string { + return location.Url } diff --git a/weed/replication/source/filer_source.go b/weed/replication/source/filer_source.go index c3ef8835c..ff4f2eb26 100644 --- a/weed/replication/source/filer_source.go +++ b/weed/replication/source/filer_source.go @@ -111,8 +111,8 @@ func (fs *FilerSource) WithFilerClient(fn func(filer_pb.SeaweedFilerClient) erro } -func (fs *FilerSource) AdjustedUrl(hostAndPort string) string { - return hostAndPort +func (fs *FilerSource) AdjustedUrl(location *filer_pb.Location) string { + return location.Url } func volumeId(fileId string) string { diff --git a/weed/s3api/s3api_handlers.go b/weed/s3api/s3api_handlers.go index fa706cd1c..6935c75bd 100644 --- a/weed/s3api/s3api_handlers.go +++ b/weed/s3api/s3api_handlers.go @@ -50,8 +50,8 @@ func (s3a *S3ApiServer) WithFilerClient(fn func(filer_pb.SeaweedFilerClient) err }, s3a.option.FilerGrpcAddress, s3a.option.GrpcDialOption) } -func (s3a *S3ApiServer) AdjustedUrl(hostAndPort string) string { - return hostAndPort +func (s3a *S3ApiServer) AdjustedUrl(location *filer_pb.Location) string { + return location.Url } // If none of the http routes match respond with MethodNotAllowed diff --git a/weed/server/webdav_server.go b/weed/server/webdav_server.go index f13e73a7b..ee5fa5f65 100644 --- a/weed/server/webdav_server.go +++ b/weed/server/webdav_server.go @@ -118,8 +118,8 @@ func (fs *WebDavFileSystem) WithFilerClient(fn func(filer_pb.SeaweedFilerClient) }, fs.option.FilerGrpcAddress, fs.option.GrpcDialOption) } -func (fs *WebDavFileSystem) AdjustedUrl(hostAndPort string) string { - return hostAndPort +func (fs *WebDavFileSystem) AdjustedUrl(location *filer_pb.Location) string { + return location.Url } func clearName(name string) (string, error) { diff --git a/weed/shell/commands.go b/weed/shell/commands.go index f61ed9f82..1a937ad53 100644 --- a/weed/shell/commands.go +++ b/weed/shell/commands.go @@ -102,8 +102,8 @@ func (ce *CommandEnv) WithFilerClient(fn func(filer_pb.SeaweedFilerClient) error } -func (ce *CommandEnv) AdjustedUrl(hostAndPort string) string { - return hostAndPort +func (ce *CommandEnv) AdjustedUrl(location *filer_pb.Location) string { + return location.Url } func parseFilerUrl(entryPath string) (filerServer string, filerPort int64, path string, err error) {