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

Fixes https://github.com/flutter/flutter/issues/14578.
This commit is contained in:
Michael Goderbauer
2018-08-28 09:37:34 -07:00
committed by GitHub
parent 7a07b28c93
commit 91dde9074a
2 changed files with 11 additions and 28 deletions

View File

@@ -172,18 +172,6 @@ fi
(upgrade_flutter) 3< "$PROG_NAME"
set +e
# FLUTTER_TOOL_ARGS isn't quoted below, because it is meant to be considered as
# separate space-separated args.
"$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" "$@"

View File

@@ -103,7 +103,7 @@ GOTO :after_subroutine
SET update_dart_bin=%FLUTTER_ROOT%/bin/internal/update_dart_sdk.ps1
REM Escape apostrophes from the executable path
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" (
ECHO Error: Unable to update Dart SDK. Retrying...
timeout /t 5 /nobreak
@@ -153,7 +153,7 @@ GOTO :after_subroutine
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" (
ECHO Error: Unable to create dart snapshot for flutter tool.
SET exit_code=%ERRORLEVEL%
@@ -166,20 +166,15 @@ GOTO :after_subroutine
:after_subroutine
CALL "%dart%" %FLUTTER_TOOL_ARGS% "%snapshot_path%" %*
SET exit_code=%ERRORLEVEL%
REM The VM exits with code 253 if the snapshot version is out-of-date.
IF "%exit_code%" EQU "253" (
CALL "%dart%" --snapshot="%snapshot_path%" --packages="%flutter_tools_dir%\.packages" "%script_path%"
SET exit_code=%ERRORLEVEL%
IF "%exit_code%" EQU "253" (
ECHO Error: Unable to create dart snapshot for flutter tool.
EXIT /B %exit_code%
)
CALL "%dart%" %FLUTTER_TOOL_ARGS% "%snapshot_path%" %*
SET exit_code=%ERRORLEVEL%
)
REM Chaining the call to 'dart' and 'exit' with an ampersand ensures that
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 part of 'flutter upgrade') modifies this batch script while it is executing.
REM
REM Do not use the CALL command in the next line to execute Dart. CALL causes
REM Windows to re-read the line from disk after the CALL command has finished
REM regardless of the ampersand chain.
"%dart%" %FLUTTER_TOOL_ARGS% "%snapshot_path%" %* & exit /B !ERRORLEVEL!
:final_exit
EXIT /B %exit_code%