Attempt to set LongPathsEnabled if exists and not 1

If LongPathsEnabled is set, but not set to 1, attempt to modify the
value to 1.

Bug: https://github.com/flutter/flutter/issues/82184
Change-Id: I80189420f4c093ed914b19d5ed7bf34f4a6dc439
Reviewed-on: https://flutter-review.googlesource.com/c/recipes/+/13360
Commit-Queue: Chris Bracken <cbracken@google.com>
Reviewed-by: Zach Anderson <zra@google.com>
diff --git a/recipe_modules/os_utils/resources/long_paths.ps1 b/recipe_modules/os_utils/resources/long_paths.ps1
index d9e8943..0fa9716 100644
--- a/recipe_modules/os_utils/resources/long_paths.ps1
+++ b/recipe_modules/os_utils/resources/long_paths.ps1
@@ -5,12 +5,24 @@
 $filesystemKey = "HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem"
 
 if (Get-ItemProperty -Path $filesystemKey -Name "LongPathsEnabled") {
-  # Key is already set, do nothing
+  # Key is already set, if it's not 1, set it
   echo "LongPathsEnabled is already set on machine"
+  $longPathsEnabled = Get-ItemPropertyValue `
+      -Path "$filesystemKey" `
+      -Name "LongPathsEnabled"
+  if (-not $longPathsEnabled) {
+    Set-ItemProperty `
+      -Path "$filesystemKey" `
+      -Name "LongPathsEnabled" `
+      -Value 1 `
+      -Force
+  }
+
 } else {
   # LongPathsEnabled value is not yet present, set it
   echo "LongPathsEnabled is not yet set on machine; setting."
-  New-ItemProperty -Path "$filesystemKey" `
+  New-ItemProperty `
+      -Path "$filesystemKey" `
       -Name "LongPathsEnabled" `
       -Value 1 `
       -PropertyType DWORD `