diff options
| author | Chris Lu <chris.lu@gmail.com> | 2020-03-23 00:01:34 -0700 |
|---|---|---|
| committer | Chris Lu <chris.lu@gmail.com> | 2020-03-23 00:01:34 -0700 |
| commit | c0f0fdb3baeb6e9852c6876b23c1404b2c5e833d (patch) | |
| tree | b52ffd7ac51e5c0472f0d0e2a8f5b1338cbf270c /weed/filer2/stream.go | |
| parent | fbca6b29bd48eeed54511a9b53b937597eee5d19 (diff) | |
| download | seaweedfs-c0f0fdb3baeb6e9852c6876b23c1404b2c5e833d.tar.xz seaweedfs-c0f0fdb3baeb6e9852c6876b23c1404b2c5e833d.zip | |
refactoring
Diffstat (limited to 'weed/filer2/stream.go')
| -rw-r--r-- | weed/filer2/stream.go | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/weed/filer2/stream.go b/weed/filer2/stream.go index 8819070ff..bb24312fd 100644 --- a/weed/filer2/stream.go +++ b/weed/filer2/stream.go @@ -71,13 +71,13 @@ func NewChunkStreamReaderFromFiler(masterClient *wdclient.MasterClient, chunks [ } } -func NewChunkStreamReaderFromClient(filerClient FilerClient, chunkViews []*ChunkView) *ChunkStreamReader { +func NewChunkStreamReaderFromClient(filerClient filer_pb.FilerClient, chunkViews []*ChunkView) *ChunkStreamReader { return &ChunkStreamReader{ chunkViews: chunkViews, lookupFileId: func(fileId string) (targetUrl string, err error) { err = filerClient.WithFilerClient(func(client filer_pb.SeaweedFilerClient) error { - vid := fileIdToVolumeId(fileId) + vid := VolumeId(fileId) resp, err := client.LookupVolume(context.Background(), &filer_pb.LookupVolumeRequest{ VolumeIds: []string{vid}, }) @@ -178,10 +178,11 @@ func (c *ChunkStreamReader) fetchChunkToBuffer(chunkView *ChunkView) error { return nil } -func fileIdToVolumeId(fileId string) (volumeId string) { - parts := strings.Split(fileId, ",") - if len(parts) != 2 { - return fileId +func VolumeId(fileId string) string { + lastCommaIndex := strings.LastIndex(fileId, ",") + if lastCommaIndex > 0 { + return fileId[:lastCommaIndex] } - return parts[0] + return fileId } + |
