Fix locking to work with flutter and dart running simultaneously (#133350)
This commit is contained in:
parent
347f7bac94
commit
c4e1a1b387
3
bin/dart
3
bin/dart
@ -45,6 +45,7 @@ function follow_links() (
|
|||||||
|
|
||||||
PROG_NAME="$(follow_links "${BASH_SOURCE[0]}")"
|
PROG_NAME="$(follow_links "${BASH_SOURCE[0]}")"
|
||||||
BIN_DIR="$(cd "${PROG_NAME%/*}" ; pwd -P)"
|
BIN_DIR="$(cd "${PROG_NAME%/*}" ; pwd -P)"
|
||||||
|
SHARED_NAME="$BIN_DIR/internal/shared.sh"
|
||||||
OS="$(uname -s)"
|
OS="$(uname -s)"
|
||||||
|
|
||||||
# If we're on Windows, invoke the batch script instead to get proper locking.
|
# If we're on Windows, invoke the batch script instead to get proper locking.
|
||||||
@ -53,6 +54,6 @@ if [[ $OS =~ MINGW.* || $OS =~ CYGWIN.* || $OS =~ MSYS.* ]]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# To define `shared::execute()` function
|
# To define `shared::execute()` function
|
||||||
source "$BIN_DIR/internal/shared.sh"
|
source "$SHARED_NAME"
|
||||||
|
|
||||||
shared::execute "$@"
|
shared::execute "$@"
|
||||||
|
@ -50,6 +50,7 @@ function follow_links() (
|
|||||||
|
|
||||||
PROG_NAME="$(follow_links "${BASH_SOURCE[0]}")"
|
PROG_NAME="$(follow_links "${BASH_SOURCE[0]}")"
|
||||||
BIN_DIR="$(cd "${PROG_NAME%/*}" ; pwd -P)"
|
BIN_DIR="$(cd "${PROG_NAME%/*}" ; pwd -P)"
|
||||||
|
SHARED_NAME="$BIN_DIR/internal/shared.sh"
|
||||||
OS="$(uname -s)"
|
OS="$(uname -s)"
|
||||||
|
|
||||||
# If we're on Windows, invoke the batch script instead to get proper locking.
|
# If we're on Windows, invoke the batch script instead to get proper locking.
|
||||||
@ -58,6 +59,6 @@ if [[ $OS =~ MINGW.* || $OS =~ CYGWIN.* || $OS =~ MSYS.* ]]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# To define `shared::execute()` function
|
# To define `shared::execute()` function
|
||||||
source "$BIN_DIR/internal/shared.sh"
|
source "$SHARED_NAME"
|
||||||
|
|
||||||
shared::execute "$@"
|
shared::execute "$@"
|
||||||
|
@ -229,7 +229,23 @@ function shared::execute() {
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
upgrade_flutter 7< "$PROG_NAME"
|
# File descriptor 7 is prepared here so that we can use it with
|
||||||
|
# flock(1) in _lock() (see above).
|
||||||
|
#
|
||||||
|
# We use number 7 because it's a luckier number than 3; luck is
|
||||||
|
# important when making locks work reliably. Also because that way
|
||||||
|
# if anyone is redirecting other file descriptors there's less
|
||||||
|
# chance of a conflict.
|
||||||
|
#
|
||||||
|
# In any case, the file we redirect into this file descriptor is
|
||||||
|
# this very source file you are reading right now, because that's
|
||||||
|
# the only file we can truly guarantee exists, since we're running
|
||||||
|
# it. We don't use PROG_NAME because otherwise if you run `dart` and
|
||||||
|
# `flutter` simultaneously they'll end up using different lock files
|
||||||
|
# and will corrupt each others' downloads.
|
||||||
|
#
|
||||||
|
# SHARED_NAME itself is prepared by the caller script.
|
||||||
|
upgrade_flutter 7< "$SHARED_NAME"
|
||||||
|
|
||||||
BIN_NAME="$(basename "$PROG_NAME")"
|
BIN_NAME="$(basename "$PROG_NAME")"
|
||||||
case "$BIN_NAME" in
|
case "$BIN_NAME" in
|
||||||
|
Loading…
x
Reference in New Issue
Block a user