Unverified Commit c4e1a1b3 authored by Ian Hickson's avatar Ian Hickson Committed by GitHub

Fix locking to work with flutter and dart running simultaneously (#133350)

parent 347f7bac
......@@ -45,6 +45,7 @@ function follow_links() (
PROG_NAME="$(follow_links "${BASH_SOURCE[0]}")"
BIN_DIR="$(cd "${PROG_NAME%/*}" ; pwd -P)"
SHARED_NAME="$BIN_DIR/internal/shared.sh"
OS="$(uname -s)"
# 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
# To define `shared::execute()` function
source "$BIN_DIR/internal/shared.sh"
source "$SHARED_NAME"
shared::execute "$@"
......@@ -50,6 +50,7 @@ function follow_links() (
PROG_NAME="$(follow_links "${BASH_SOURCE[0]}")"
BIN_DIR="$(cd "${PROG_NAME%/*}" ; pwd -P)"
SHARED_NAME="$BIN_DIR/internal/shared.sh"
OS="$(uname -s)"
# 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
# To define `shared::execute()` function
source "$BIN_DIR/internal/shared.sh"
source "$SHARED_NAME"
shared::execute "$@"
......@@ -229,7 +229,23 @@ function shared::execute() {
exit 1
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")"
case "$BIN_NAME" in
......
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