@@ -72,7 +72,7 @@ func (t *blobTraverser) IsDirectory(isSource bool) bool {
72
72
return isDirDirect
73
73
}
74
74
75
- _ , isSingleBlob , _ , err := t .getPropertiesIfSingleBlob ()
75
+ _ , _ , isDirStub , err := t .getPropertiesIfSingleBlob ()
76
76
77
77
if stgErr , ok := err .(azblob.StorageError ); ok {
78
78
// We know for sure this is a single blob still, let it walk on through to the traverser.
@@ -81,7 +81,29 @@ func (t *blobTraverser) IsDirectory(isSource bool) bool {
81
81
}
82
82
}
83
83
84
- return ! isSingleBlob
84
+ if err == nil {
85
+ return isDirStub
86
+ }
87
+
88
+ blobURLParts := azblob .NewBlobURLParts (* t .rawURL )
89
+ containerRawURL := copyHandlerUtil {}.getContainerUrl (blobURLParts )
90
+ containerURL := azblob .NewContainerURL (containerRawURL , t .p )
91
+ searchPrefix := strings .TrimSuffix (blobURLParts .BlobName , common .AZCOPY_PATH_SEPARATOR_STRING ) + common .AZCOPY_PATH_SEPARATOR_STRING
92
+ resp , err := containerURL .ListBlobsFlatSegment (t .ctx , azblob.Marker {}, azblob.ListBlobsSegmentOptions {Prefix : searchPrefix , MaxResults : 1 })
93
+ if err != nil {
94
+ if azcopyScanningLogger != nil {
95
+ msg := fmt .Sprintf ("Failed to check if the destination is a folder or a file (Azure Files). Assuming the destination is a file: %s" , err )
96
+ azcopyScanningLogger .Log (pipeline .LogError , msg )
97
+ }
98
+ return false
99
+ }
100
+
101
+ if len (resp .Segment .BlobItems ) == 0 {
102
+ //Not a directory
103
+ return false
104
+ }
105
+
106
+ return true
85
107
}
86
108
87
109
func (t * blobTraverser ) getPropertiesIfSingleBlob () (props * azblob.BlobGetPropertiesResponse , isBlob bool , isDirStub bool , err error ) {
0 commit comments