Unverified Commit 9c588f32 authored by jensjoha's avatar jensjoha Committed by GitHub

Fix flutter tool crash on upgrade caused by app-jit (#111879)

Fix flutter tool crash on upgrade caused by app-jit
parent 4bc714fd
......@@ -16,6 +16,7 @@ SETLOCAL
SET flutter_tools_dir=%FLUTTER_ROOT%\packages\flutter_tools
SET cache_dir=%FLUTTER_ROOT%\bin\cache
SET snapshot_path=%cache_dir%\flutter_tools.snapshot
SET snapshot_path_old=%cache_dir%\flutter_tools.snapshot.old
SET stamp_path=%cache_dir%\flutter_tools.stamp
SET script_path=%flutter_tools_dir%\bin\flutter_tools.dart
SET dart_sdk_path=%cache_dir%\dart-sdk
......@@ -170,6 +171,21 @@ GOTO :after_subroutine
POPD
REM Move the old snapshot - we can't just overwrite it as the VM might currently have it
REM memory mapped (e.g. on flutter upgrade), and deleting it might not work if the file
REM is in use. For downloading a new dart sdk the folder is moved, so we take the same
REM approach of moving the file here.
SET /A snapshot_path_suffix=1
:move_old_snapshot
IF EXIST "%snapshot_path_old%%snapshot_path_suffix%" (
SET /A snapshot_path_suffix+=1
GOTO move_old_snapshot
) ELSE (
IF EXIST "%snapshot_path%" (
MOVE "%snapshot_path%" "%snapshot_path_old%%snapshot_path_suffix%" 2> NUL > NUL
)
)
IF "%FLUTTER_TOOL_ARGS%" == "" (
"%dart%" --verbosity=error --snapshot="%snapshot_path%" --snapshot-kind="app-jit" --packages="%flutter_tools_dir%\.dart_tool\package_config.json" --no-enable-mirrors "%script_path%" > NUL
) else (
......@@ -182,6 +198,9 @@ GOTO :after_subroutine
)
>"%stamp_path%" ECHO %compilekey%
REM Try to delete any old snapshots now. Swallow any errors though.
DEL "%snapshot_path%.old*" 2> NUL > NUL
REM Exit Subroutine
EXIT /B
......
......@@ -154,9 +154,22 @@ function upgrade_flutter () (
fi
pub_upgrade_with_retry
# Move the old snapshot - we can't just overwrite it as the VM might currently have it
# memory mapped (e.g. on flutter upgrade). For downloading a new dart sdk the folder is moved,
# so we take the same approach of moving the file here.
SNAPSHOT_PATH_OLD="$SNAPSHOT_PATH.old"
if [ -f "$SNAPSHOT_PATH" ]; then
mv "$SNAPSHOT_PATH" "$SNAPSHOT_PATH_OLD"
fi
# Compile...
"$DART" --verbosity=error --disable-dart-dev $FLUTTER_TOOL_ARGS --snapshot="$SNAPSHOT_PATH" --snapshot-kind="app-jit" --packages="$FLUTTER_TOOLS_DIR/.dart_tool/package_config.json" --no-enable-mirrors "$SCRIPT_PATH" > /dev/null
echo "$compilekey" > "$STAMP_PATH"
# Delete any temporary snapshot path.
if [ -f "$SNAPSHOT_PATH_OLD" ]; then
rm -f "$SNAPSHOT_PATH_OLD"
fi
fi
# The exit here is extraneous since the function is run in a subshell, but
# this serves as documentation that running the function in a subshell is
......
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