mirror of
https://github.com/rclone/rclone.git
synced 2024-11-23 07:41:36 +08:00
azureblob: fix directory marker detection after SDK upgrade
When the SDK was upgraded it started delivering metadata where the keys were not in lower case as per the old SDK. Rclone normalises the case of the keys for storage in the Object, but the directory marker check was being done with the unnormalised keys as it needs to be done before the Object is created. This fixes the directory marker check to do a case insensitive compare of the metadata keys.
This commit is contained in:
parent
43bf177ff7
commit
3d291da0f6
|
@ -988,13 +988,18 @@ func (o *Object) updateMetadataWithModTime(modTime time.Time) {
|
||||||
func isDirectoryMarker(size int64, metadata map[string]string, remote string) bool {
|
func isDirectoryMarker(size int64, metadata map[string]string, remote string) bool {
|
||||||
// Directory markers are 0 length
|
// Directory markers are 0 length
|
||||||
if size == 0 {
|
if size == 0 {
|
||||||
// Note that metadata with hdi_isfolder = true seems to be a
|
|
||||||
// defacto standard for marking blobs as directories.
|
|
||||||
endsWithSlash := strings.HasSuffix(remote, "/")
|
endsWithSlash := strings.HasSuffix(remote, "/")
|
||||||
if endsWithSlash || remote == "" || metadata["hdi_isfolder"] == "true" {
|
if endsWithSlash || remote == "" {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
// Note that metadata with hdi_isfolder = true seems to be a
|
||||||
|
// defacto standard for marking blobs as directories.
|
||||||
|
// Note also that the metadata hasn't been normalised to lower case yet
|
||||||
|
for k, v := range metadata {
|
||||||
|
if strings.EqualFold(k, "hdi_isfolder") && v == "true" {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
@ -1007,13 +1012,18 @@ func isDirectoryMarker(size int64, metadata map[string]string, remote string) bo
|
||||||
func isDirectoryMarkerP(size int64, metadata map[string]*string, remote string) bool {
|
func isDirectoryMarkerP(size int64, metadata map[string]*string, remote string) bool {
|
||||||
// Directory markers are 0 length
|
// Directory markers are 0 length
|
||||||
if size == 0 {
|
if size == 0 {
|
||||||
// Note that metadata with hdi_isfolder = true seems to be a
|
|
||||||
// defacto standard for marking blobs as directories.
|
|
||||||
endsWithSlash := strings.HasSuffix(remote, "/")
|
endsWithSlash := strings.HasSuffix(remote, "/")
|
||||||
if endsWithSlash || remote == "" || (metadata["hdi_isfolder"] != nil && *metadata["hdi_isfolder"] == "true") {
|
if endsWithSlash || remote == "" {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
// Note that metadata with hdi_isfolder = true seems to be a
|
||||||
|
// defacto standard for marking blobs as directories.
|
||||||
|
// Note also that the metadata hasn't been normalised to lower case yet
|
||||||
|
for k, pv := range metadata {
|
||||||
|
if strings.EqualFold(k, "hdi_isfolder") && pv != nil && *pv == "true" {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user