azblob: update to the latest SDK

Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
This commit is contained in:
Nicola Murino
2023-02-10 17:34:21 +01:00
parent b925504795
commit b084564c3f
4 changed files with 43 additions and 47 deletions

View File

@@ -180,15 +180,7 @@ func (fs *AzureBlobFs) Stat(name string) (os.FileInfo, error) {
attrs, err := fs.headObject(name)
if err == nil {
contentType := util.GetStringFromPointer(attrs.ContentType)
isDir := contentType == dirMimeType
if !isDir {
for k, v := range attrs.Metadata {
if strings.ToLower(k) == azFolderKey {
isDir = (v == "true")
break
}
}
}
isDir := checkDirectoryMarkers(contentType, attrs.Metadata)
metric.AZListObjectsCompleted(nil)
return updateFileInfoModTime(fs.getStorageID(), name, NewFileInfo(name, isDir,
util.GetIntFromPointer(attrs.ContentLength),
@@ -245,11 +237,11 @@ func (fs *AzureBlobFs) Create(name string, flag int) (File, *PipeWriter, func(),
p := NewPipeWriter(w)
headers := blob.HTTPHeaders{}
var contentType string
var metadata map[string]string
var metadata map[string]*string
if flag == -1 {
contentType = dirMimeType
metadata = map[string]string{
azFolderKey: "true",
metadata = map[string]*string{
azFolderKey: util.NilIfEmpty("true"),
}
} else {
contentType = mime.TypeByExtension(path.Ext(name))
@@ -890,9 +882,9 @@ func (fs *AzureBlobFs) downloadPart(ctx context.Context, blockBlob *blockblob.Cl
if err != nil {
return err
}
defer resp.BlobClientDownloadResponse.Body.Close()
defer resp.DownloadResponse.Body.Close()
_, err = io.ReadAtLeast(resp.BlobClientDownloadResponse.Body, buf, int(count))
_, err = io.ReadAtLeast(resp.DownloadResponse.Body, buf, int(count))
if err != nil {
return err
}
@@ -983,7 +975,7 @@ func (fs *AzureBlobFs) handleMultipartDownload(ctx context.Context, blockBlob *b
}
func (fs *AzureBlobFs) handleMultipartUpload(ctx context.Context, reader io.Reader,
blockBlob *blockblob.Client, httpHeaders *blob.HTTPHeaders, metadata map[string]string,
blockBlob *blockblob.Client, httpHeaders *blob.HTTPHeaders, metadata map[string]*string,
) error {
partSize := fs.config.UploadPartSize
guard := make(chan struct{}, fs.config.UploadConcurrency)
@@ -1153,7 +1145,7 @@ func getAzContainerClientOptions() *container.ClientOptions {
return &container.ClientOptions{
ClientOptions: azcore.ClientOptions{
Telemetry: policy.TelemetryOptions{
ApplicationID: fmt.Sprintf("SFTPGo-%v_%v", version.Version, version.CommitHash),
ApplicationID: fmt.Sprintf("SFTPGo-%s", version.CommitHash),
},
},
}