From 849c4414552528d326c7adc053670abbfd820485 Mon Sep 17 00:00:00 2001 From: aneesh-n <99904+aneesh-n@users.noreply.github.com> Date: Sun, 11 Aug 2024 01:48:25 -0600 Subject: [PATCH] Gracefully handle invalid prepared volume names --- internal/restic/node_windows.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/internal/restic/node_windows.go b/internal/restic/node_windows.go index 6adb51f0d..2ca7e42e6 100644 --- a/internal/restic/node_windows.go +++ b/internal/restic/node_windows.go @@ -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 eaSupportedValue, exists := eaSupportedVolumesMap.Load(volumeName) if exists { + // Cache hit, immediately return the cached value return eaSupportedValue.(bool), nil } // If not found, check if EA is supported with manually prepared volume name 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 } } @@ -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 eaSupportedValue, exists := eaSupportedVolumesMap.Load(volumeNameActual) if exists { + // Cache hit, immediately return the cached value 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