This commit is contained in:
Anubhuti Shruti 2024-11-04 15:09:33 +05:30
Родитель 49ce08bf69
Коммит d17cd173fb
4 изменённых файлов: 17 добавлений и 118 удалений

Просмотреть файл

@ -104,7 +104,7 @@ func (bb *BlockBlob) Configure(cfg AzStorageConfig) error {
Metadata: true,
Deleted: false,
Snapshots: false,
Permissions: true,
Permissions: false,
}
return nil
@ -583,11 +583,21 @@ func (bb *BlockBlob) List(prefix string, marker *string, count int32) ([]*intern
return blobList, nil, err
}
} else {
var mode os.FileMode
if blobInfo.Properties.Permissions != nil {
mode, err = getFileMode(*blobInfo.Properties.Permissions)
if err != nil {
log.Err("BlockBlob::List : Failed to get file mode for %s [%s]", *blobInfo.Name, err.Error())
return blobList, nil, err
}
} else {
mode = 0
}
attr = &internal.ObjAttr{
Path: split(bb.Config.prefixPath, *blobInfo.Name),
Name: filepath.Base(*blobInfo.Name),
Size: *blobInfo.Properties.ContentLength,
Mode: 0,
Mode: mode,
Mtime: *blobInfo.Properties.LastModified,
Atime: dereferenceTime(blobInfo.Properties.LastAccessedOn, *blobInfo.Properties.LastModified),
Ctime: *blobInfo.Properties.LastModified,
@ -621,7 +631,7 @@ func (bb *BlockBlob) List(prefix string, marker *string, count int32) ([]*intern
// marker file not found in current iteration, so we need to manually check attributes via REST
_, err := bb.getAttrUsingRest(*blobInfo.Name)
// marker file also not found via manual check, safe to add to list
if err == syscall.ENOENT {
if err == syscall.ENOENT || bb.listDetails.Permissions {
// For these dirs we get only the name and no other properties so hardcoding time to current time
name := strings.TrimSuffix(*blobInfo.Name, "/")
attr := &internal.ObjAttr{

Просмотреть файл

@ -36,13 +36,11 @@ package azstorage
import (
"context"
"fmt"
"io/fs"
"net/url"
"os"
"path/filepath"
"strings"
"syscall"
"time"
"github.com/Azure/azure-storage-fuse/v2/common"
"github.com/Azure/azure-storage-fuse/v2/common/log"
@ -426,117 +424,8 @@ func (dl *Datalake) GetAttr(name string) (attr *internal.ObjAttr, err error) {
// This fetches the list using a marker so the caller code should handle marker logic
// If count=0 - fetch max entries
func (dl *Datalake) List(prefix string, marker *string, count int32) ([]*internal.ObjAttr, *string, error) {
dl.BlockBlob.List(prefix, marker, count)
log.Trace("Datalake::List : prefix %s, marker %s", prefix, func(marker *string) string {
if marker != nil {
return *marker
} else {
return ""
}
}(marker))
pathList := make([]*internal.ObjAttr, 0)
if count == 0 {
count = common.MaxDirListCount
}
prefixPath := filepath.Join(dl.Config.prefixPath, prefix)
if prefix != "" && prefix[len(prefix)-1] == '/' {
prefixPath += "/"
}
// Get a result segment starting with the path indicated by the current Marker.
pager := dl.Filesystem.NewListPathsPager(false, &filesystem.ListPathsOptions{
Marker: marker,
MaxResults: &count,
Prefix: &prefixPath,
})
// Process the paths returned in this result segment (if the segment is empty, the loop body won't execute)
listPath, err := pager.NextPage(context.Background())
if err != nil {
log.Err("Datalake::List : Failed to validate account with given auth %s", err.Error())
m := ""
e := storeDatalakeErrToErr(err)
if e == ErrFileNotFound { // TODO: should this be checked for list calls
return pathList, &m, syscall.ENOENT
} else if e == InvalidPermission {
return pathList, &m, syscall.EACCES
} else {
return pathList, &m, err
}
}
// Process the paths returned in this result segment (if the segment is empty, the loop body won't execute)
for _, pathInfo := range listPath.Paths {
var attr *internal.ObjAttr
var lastModifiedTime time.Time
if dl.Config.disableSymlink {
var mode fs.FileMode
if pathInfo.Permissions != nil {
mode, err = getFileMode(*pathInfo.Permissions)
if err != nil {
log.Err("Datalake::List : Failed to get file mode for %s [%s]", *pathInfo.Name, err.Error())
m := ""
return pathList, &m, err
}
} else {
// This happens when a blob account is mounted with type:adls
log.Err("Datalake::List : Failed to get file permissions for %s", *pathInfo.Name)
}
var contentLength int64 = 0
if pathInfo.ContentLength != nil {
contentLength = *pathInfo.ContentLength
} else {
// This happens when a blob account is mounted with type:adls
log.Err("Datalake::List : Failed to get file length for %s", *pathInfo.Name)
}
if pathInfo.LastModified != nil {
lastModifiedTime, err = time.Parse(time.RFC1123, *pathInfo.LastModified)
if err != nil {
log.Err("Datalake::List : Failed to get last modified time for %s [%s]", *pathInfo.Name, err.Error())
}
}
attr = &internal.ObjAttr{
Path: *pathInfo.Name,
Name: filepath.Base(*pathInfo.Name),
Size: contentLength,
Mode: mode,
Mtime: lastModifiedTime,
Atime: lastModifiedTime,
Ctime: lastModifiedTime,
Crtime: lastModifiedTime,
Flags: internal.NewFileBitMap(),
}
if pathInfo.IsDirectory != nil && *pathInfo.IsDirectory {
attr.Flags = internal.NewDirBitMap()
attr.Mode = attr.Mode | os.ModeDir
}
} else {
attr, err = dl.GetAttr(*pathInfo.Name)
if err != nil {
log.Err("Datalake::List : Failed to get properties for %s [%s]", *pathInfo.Name, err.Error())
m := ""
return pathList, &m, err
}
}
// Note: Datalake list paths does not return metadata/properties.
// To account for this and accurately return attributes when needed,
// we have a flag for whether or not metadata has been retrieved.
// If this flag is not set the attribute cache will call get attributes
// to fetch metadata properties.
// Any method that populates the metadata should set the attribute flag.
// Alternatively, if you want Datalake list paths to return metadata/properties as well.
// pass CLI parameter --no-symlinks=false in the mount command.
pathList = append(pathList, attr)
}
return pathList, listPath.Continuation, nil
dl.BlockBlob.listDetails.Permissions = true
return dl.BlockBlob.List(prefix, marker, count)
}
// ReadToFile : Download a file to a local file

2
go.mod
Просмотреть файл

@ -60,4 +60,6 @@ require (
replace github.com/spf13/cobra => github.com/gapra-msft/cobra v1.4.1-0.20220411185530-5b83e8ba06dd
replace github.com/Azure/azure-sdk-for-go/sdk/storage/azblob => /home/anubhuti/Downloads/azure-sdk-for-go/sdk/storage/azblob
//replace github.com/Azure/azure-storage-azcopy/v10 v10.19.1-0.20230717101935-ab8ff0a85e48 => <local path>/azure-storage-azcopy

2
go.sum
Просмотреть файл

@ -8,8 +8,6 @@ github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0 h1:ywEEhmNahHBihViHepv3xP
github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0/go.mod h1:iZDifYGJTIgIIkYRNWPENUnqx6bJ2xnSDFI2tjwZNuY=
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/storage/armstorage v1.6.0 h1:PiSrjRPpkQNjrM8H0WwKMnZUdu1RGMtd/LdGKUrOo+c=
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/storage/armstorage v1.6.0/go.mod h1:oDrbWx4ewMylP7xHivfgixbfGBT6APAwsSoHRKotnIc=
github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v1.5.0-beta.1.0.20241101205320-058b4f1276f8 h1:lEIiZVUYqfTefmla/1VdVN25KtD+Ocv6YU/aYmrO/go=
github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v1.5.0-beta.1.0.20241101205320-058b4f1276f8/go.mod h1:PXe2h+LKcWTX9afWdZoHyODqR4fBa5boUM/8uJfZ0Jo=
github.com/Azure/azure-sdk-for-go/sdk/storage/azdatalake v1.3.0-beta.1.0.20241101205320-058b4f1276f8 h1:/2kDSLunMEZCmppek7SI+GpnRhfPY5nuu4Sfk0pBMCQ=
github.com/Azure/azure-sdk-for-go/sdk/storage/azdatalake v1.3.0-beta.1.0.20241101205320-058b4f1276f8/go.mod h1:CgYxIvUeJo6+7LdnaArwd1Mpk02d9ATikuJviLrxU5E=
github.com/AzureAD/microsoft-authentication-extensions-for-go/cache v0.1.1 h1:WJTmL004Abzc5wDB5VtZG2PJk5ndYDgVacGqfirKxjM=