Commit 294376fb authored by Ian Hickson's avatar Ian Hickson Committed by GitHub

fix reentrant locking in pub upgrade (#4556)

parent 0e50ee6e
...@@ -55,7 +55,7 @@ class Cache { ...@@ -55,7 +55,7 @@ class Cache {
locked = true; locked = true;
} on FileSystemException { } on FileSystemException {
if (!printed) { if (!printed) {
printStatus('Waiting to be able to obtain lock of Flutter cache directory...'); printStatus('Waiting to be able to obtain lock of Flutter binary artifacts directory...');
printed = true; printed = true;
} }
await new Future/*<Null>*/.delayed(const Duration(milliseconds: 50)); await new Future/*<Null>*/.delayed(const Duration(milliseconds: 50));
...@@ -65,9 +65,8 @@ class Cache { ...@@ -65,9 +65,8 @@ class Cache {
/// Releases the lock. This is not necessary unless the process is long-lived. /// Releases the lock. This is not necessary unless the process is long-lived.
static void releaseLockEarly() { static void releaseLockEarly() {
if (!_lockEnabled) if (!_lockEnabled || _lock == null)
return; return;
assert(_lock != null);
_lock.closeSync(); _lock.closeSync();
_lock = null; _lock = null;
} }
......
...@@ -45,10 +45,13 @@ class UpgradeCommand extends FlutterCommand { ...@@ -45,10 +45,13 @@ class UpgradeCommand extends FlutterCommand {
return code; return code;
// Check for and download any engine and pkg/ updates. // Check for and download any engine and pkg/ updates.
// We run the 'flutter' shell script re-entrantly here
// so that it will download the updated Dart and so forth
// if necessary.
printStatus(''); printStatus('');
printStatus('Upgrading engine...'); printStatus('Upgrading engine...');
code = await runCommandAndStreamOutput(<String>[ code = await runCommandAndStreamOutput(<String>[
'bin/flutter', '--no-color', 'precache' 'bin/flutter', '--no-lock', '--no-color', 'precache'
], workingDirectory: Cache.flutterRoot); ], workingDirectory: Cache.flutterRoot);
printStatus(''); printStatus('');
......
...@@ -48,6 +48,11 @@ class FlutterCommandRunner extends CommandRunner { ...@@ -48,6 +48,11 @@ class FlutterCommandRunner extends CommandRunner {
negatable: true, negatable: true,
hide: !verboseHelp, hide: !verboseHelp,
help: 'Whether to use terminal colors.'); help: 'Whether to use terminal colors.');
argParser.addFlag('lock',
negatable: true,
hide: !verboseHelp,
help: 'Whether to lock the Flutter binary artifacts directory while running. (This prevents multiple simultaneous Flutter instances from colliding.)',
defaultsTo: true);
argParser.addFlag('suppress-analytics', argParser.addFlag('suppress-analytics',
negatable: false, negatable: false,
hide: !verboseHelp, hide: !verboseHelp,
...@@ -142,7 +147,8 @@ class FlutterCommandRunner extends CommandRunner { ...@@ -142,7 +147,8 @@ class FlutterCommandRunner extends CommandRunner {
// enginePath's initialiser uses it). // enginePath's initialiser uses it).
Cache.flutterRoot = path.normalize(path.absolute(globalResults['flutter-root'])); Cache.flutterRoot = path.normalize(path.absolute(globalResults['flutter-root']));
await Cache.lock(); if (globalResults['lock']);
await Cache.lock();
if (globalResults['suppress-analytics']) if (globalResults['suppress-analytics'])
flutterUsage.suppressAnalytics = true; flutterUsage.suppressAnalytics = true;
......
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