Unverified Commit 91dde907 authored by Michael Goderbauer's avatar Michael Goderbauer Committed by GitHub

No more nasty errors during flutter upgrade/channel on Windows (#21085)

Fixes https://github.com/flutter/flutter/issues/14578.
parent 7a07b28c
...@@ -172,18 +172,6 @@ fi ...@@ -172,18 +172,6 @@ fi
(upgrade_flutter) 3< "$PROG_NAME" (upgrade_flutter) 3< "$PROG_NAME"
set +e
# FLUTTER_TOOL_ARGS isn't quoted below, because it is meant to be considered as # FLUTTER_TOOL_ARGS isn't quoted below, because it is meant to be considered as
# separate space-separated args. # separate space-separated args.
"$DART" $FLUTTER_TOOL_ARGS "$SNAPSHOT_PATH" "$@" "$DART" $FLUTTER_TOOL_ARGS "$SNAPSHOT_PATH" "$@"
# The VM exits with code 253 if the snapshot version is out-of-date.
# If it is, we need to snapshot it again.
EXIT_CODE=$?
if [[ $EXIT_CODE != 253 ]]; then
exit $EXIT_CODE
fi
set -e
"$DART" --snapshot="$SNAPSHOT_PATH" --packages="$FLUTTER_TOOLS_DIR/.packages" "$SCRIPT_PATH"
"$DART" $FLUTTER_TOOL_ARGS "$SNAPSHOT_PATH" "$@"
...@@ -103,7 +103,7 @@ GOTO :after_subroutine ...@@ -103,7 +103,7 @@ GOTO :after_subroutine
SET update_dart_bin=%FLUTTER_ROOT%/bin/internal/update_dart_sdk.ps1 SET update_dart_bin=%FLUTTER_ROOT%/bin/internal/update_dart_sdk.ps1
REM Escape apostrophes from the executable path REM Escape apostrophes from the executable path
SET "update_dart_bin=!update_dart_bin:'=''!" SET "update_dart_bin=!update_dart_bin:'=''!"
CALL PowerShell.exe -ExecutionPolicy Bypass -Command "Unblock-File -Path '%update_dart_bin%'; & '%update_dart_bin%'" PowerShell.exe -ExecutionPolicy Bypass -Command "Unblock-File -Path '%update_dart_bin%'; & '%update_dart_bin%'"
IF "%ERRORLEVEL%" NEQ "0" ( IF "%ERRORLEVEL%" NEQ "0" (
ECHO Error: Unable to update Dart SDK. Retrying... ECHO Error: Unable to update Dart SDK. Retrying...
timeout /t 5 /nobreak timeout /t 5 /nobreak
...@@ -153,7 +153,7 @@ GOTO :after_subroutine ...@@ -153,7 +153,7 @@ GOTO :after_subroutine
POPD POPD
CALL "%dart%" --snapshot="%snapshot_path%" --packages="%flutter_tools_dir%\.packages" "%script_path%" "%dart%" --snapshot="%snapshot_path%" --packages="%flutter_tools_dir%\.packages" "%script_path%"
IF "%ERRORLEVEL%" NEQ "0" ( IF "%ERRORLEVEL%" NEQ "0" (
ECHO Error: Unable to create dart snapshot for flutter tool. ECHO Error: Unable to create dart snapshot for flutter tool.
SET exit_code=%ERRORLEVEL% SET exit_code=%ERRORLEVEL%
...@@ -166,20 +166,15 @@ GOTO :after_subroutine ...@@ -166,20 +166,15 @@ GOTO :after_subroutine
:after_subroutine :after_subroutine
CALL "%dart%" %FLUTTER_TOOL_ARGS% "%snapshot_path%" %* REM Chaining the call to 'dart' and 'exit' with an ampersand ensures that
SET exit_code=%ERRORLEVEL% REM Windows reads both commands into memory once before executing them. This
REM avoids nasty errors that may otherwise occure when the dart command (e.g. as
REM The VM exits with code 253 if the snapshot version is out-of-date. REM part of 'flutter upgrade') modifies this batch script while it is executing.
IF "%exit_code%" EQU "253" ( REM
CALL "%dart%" --snapshot="%snapshot_path%" --packages="%flutter_tools_dir%\.packages" "%script_path%" REM Do not use the CALL command in the next line to execute Dart. CALL causes
SET exit_code=%ERRORLEVEL% REM Windows to re-read the line from disk after the CALL command has finished
IF "%exit_code%" EQU "253" ( REM regardless of the ampersand chain.
ECHO Error: Unable to create dart snapshot for flutter tool. "%dart%" %FLUTTER_TOOL_ARGS% "%snapshot_path%" %* & exit /B !ERRORLEVEL!
EXIT /B %exit_code%
)
CALL "%dart%" %FLUTTER_TOOL_ARGS% "%snapshot_path%" %*
SET exit_code=%ERRORLEVEL%
)
:final_exit :final_exit
EXIT /B %exit_code% EXIT /B %exit_code%
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment