diff options
| author | Chris Lu <chris.lu@gmail.com> | 2020-10-11 20:15:10 -0700 |
|---|---|---|
| committer | Chris Lu <chris.lu@gmail.com> | 2020-10-11 20:15:10 -0700 |
| commit | 723ae11db401b791925d99968ad53240c3259305 (patch) | |
| tree | 1cc9fdc63f5d16e5fd9e85b73d83291ac9e52b68 /weed/filesys | |
| parent | d5fcb0f474ac72389b89ba2d42adc4089b0f3e88 (diff) | |
| download | seaweedfs-723ae11db401b791925d99968ad53240c3259305.tar.xz seaweedfs-723ae11db401b791925d99968ad53240c3259305.zip | |
refactoring in order to adjust volume server url later
Diffstat (limited to 'weed/filesys')
| -rw-r--r-- | weed/filesys/wfs_deletion.go | 2 | ||||
| -rw-r--r-- | weed/filesys/wfs_filer_client.go | 10 | ||||
| -rw-r--r-- | weed/filesys/wfs_write.go | 8 |
3 files changed, 12 insertions, 8 deletions
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 |
