Gracefully handle invalid prepared volume names

This commit is contained in:
aneesh-n 2024-08-11 01:48:25 -06:00
parent b5b5c1fe8e
commit 849c441455
No known key found for this signature in database
GPG key ID: 6F5A52831C046F44

View file

@ -417,11 +417,13 @@ func checkAndStoreEASupport(path string) (isEASupportedVolume bool, err error) {
// First check if the manually prepared volume name is already in the map // First check if the manually prepared volume name is already in the map
eaSupportedValue, exists := eaSupportedVolumesMap.Load(volumeName) eaSupportedValue, exists := eaSupportedVolumesMap.Load(volumeName)
if exists { if exists {
// Cache hit, immediately return the cached value
return eaSupportedValue.(bool), nil return eaSupportedValue.(bool), nil
} }
// If not found, check if EA is supported with manually prepared volume name // If not found, check if EA is supported with manually prepared volume name
isEASupportedVolume, err = fs.PathSupportsExtendedAttributes(volumeName + `\`) isEASupportedVolume, err = fs.PathSupportsExtendedAttributes(volumeName + `\`)
if err != nil { // If the prepared volume name is not valid, we will next fetch the actual volume name.
if err != nil && !errors.Is(err, windows.DNS_ERROR_INVALID_NAME) {
return false, err return false, err
} }
} }
@ -434,6 +436,7 @@ func checkAndStoreEASupport(path string) (isEASupportedVolume bool, err error) {
// If the actual volume name is different, check cache for the actual volume name // If the actual volume name is different, check cache for the actual volume name
eaSupportedValue, exists := eaSupportedVolumesMap.Load(volumeNameActual) eaSupportedValue, exists := eaSupportedVolumesMap.Load(volumeNameActual)
if exists { if exists {
// Cache hit, immediately return the cached value
return eaSupportedValue.(bool), nil return eaSupportedValue.(bool), nil
} }
// If the actual volume name is different and is not in the map, again check if the new volume supports extended attributes with the actual volume name // If the actual volume name is different and is not in the map, again check if the new volume supports extended attributes with the actual volume name