mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-09-02 06:07:24 +00:00
Address Gemini Code Assist review comments
Fixed three issues identified by Gemini Code Assist:
1. HIGH: ReadFile now uses blob.CountToEnd when size is 0
- Old SDK: size=0 meant "read to end"
- New SDK: size=0 means "read 0 bytes"
- Fix: Use blob.CountToEnd (-1) to read entire blob from offset
2. MEDIUM: Use to.Ptr() instead of slice trick for DeleteSnapshots
- Replaced &[]Type{value}[0] with to.Ptr(value)
- Cleaner, more idiomatic Azure SDK pattern
- Applied to both azure_storage_client.go and azure_sink.go
3. Added missing imports:
- github.com/Azure/azure-sdk-for-go/sdk/azcore/to
These changes improve code clarity and correctness while following
Azure SDK best practices.
This commit is contained in:
@@ -8,6 +8,7 @@ import (
|
||||
"reflect"
|
||||
"strings"
|
||||
|
||||
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
|
||||
"github.com/Azure/azure-sdk-for-go/sdk/storage/azblob"
|
||||
"github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/blob"
|
||||
"github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/blockblob"
|
||||
@@ -121,6 +122,9 @@ func (az *azureRemoteStorageClient) ReadFile(loc *remote_pb.RemoteStorageLocatio
|
||||
blobClient := az.client.ServiceClient().NewContainerClient(loc.Bucket).NewBlockBlobClient(key)
|
||||
|
||||
count := size
|
||||
if count == 0 {
|
||||
count = blob.CountToEnd
|
||||
}
|
||||
downloadResp, err := blobClient.DownloadStream(context.Background(), &blob.DownloadStreamOptions{
|
||||
Range: blob.HTTPRange{
|
||||
Offset: offset,
|
||||
@@ -231,7 +235,7 @@ func (az *azureRemoteStorageClient) DeleteFile(loc *remote_pb.RemoteStorageLocat
|
||||
blobClient := az.client.ServiceClient().NewContainerClient(loc.Bucket).NewBlobClient(key)
|
||||
|
||||
_, err = blobClient.Delete(context.Background(), &blob.DeleteOptions{
|
||||
DeleteSnapshots: &[]blob.DeleteSnapshotsOptionType{blob.DeleteSnapshotsOptionTypeInclude}[0],
|
||||
DeleteSnapshots: to.Ptr(blob.DeleteSnapshotsOptionTypeInclude),
|
||||
})
|
||||
if err != nil {
|
||||
return fmt.Errorf("azure delete %s%s: %v", loc.Bucket, loc.Path, err)
|
||||
|
||||
@@ -11,6 +11,7 @@ import (
|
||||
|
||||
"github.com/Azure/azure-sdk-for-go/sdk/azcore"
|
||||
"github.com/Azure/azure-sdk-for-go/sdk/azcore/streaming"
|
||||
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
|
||||
"github.com/Azure/azure-sdk-for-go/sdk/storage/azblob"
|
||||
"github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/appendblob"
|
||||
"github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/blob"
|
||||
@@ -92,7 +93,7 @@ func (g *AzureSink) DeleteEntry(key string, isDirectory, deleteIncludeChunks boo
|
||||
|
||||
blobClient := g.client.ServiceClient().NewContainerClient(g.container).NewBlobClient(key)
|
||||
_, err := blobClient.Delete(context.Background(), &blob.DeleteOptions{
|
||||
DeleteSnapshots: &[]blob.DeleteSnapshotsOptionType{blob.DeleteSnapshotsOptionTypeInclude}[0],
|
||||
DeleteSnapshots: to.Ptr(blob.DeleteSnapshotsOptionTypeInclude),
|
||||
})
|
||||
if err != nil {
|
||||
return fmt.Errorf("azure delete %s/%s: %v", g.container, key, err)
|
||||
|
||||
Reference in New Issue
Block a user