fix reentrant locking in pub upgrade (#4556)
This commit is contained in:
@@ -55,7 +55,7 @@ class Cache {
|
||||
locked = true;
|
||||
} on FileSystemException {
|
||||
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;
|
||||
}
|
||||
await new Future/*<Null>*/.delayed(const Duration(milliseconds: 50));
|
||||
@@ -65,9 +65,8 @@ class Cache {
|
||||
|
||||
/// Releases the lock. This is not necessary unless the process is long-lived.
|
||||
static void releaseLockEarly() {
|
||||
if (!_lockEnabled)
|
||||
if (!_lockEnabled || _lock == null)
|
||||
return;
|
||||
assert(_lock != null);
|
||||
_lock.closeSync();
|
||||
_lock = null;
|
||||
}
|
||||
|
||||
@@ -45,10 +45,13 @@ class UpgradeCommand extends FlutterCommand {
|
||||
return code;
|
||||
|
||||
// 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('Upgrading engine...');
|
||||
code = await runCommandAndStreamOutput(<String>[
|
||||
'bin/flutter', '--no-color', 'precache'
|
||||
'bin/flutter', '--no-lock', '--no-color', 'precache'
|
||||
], workingDirectory: Cache.flutterRoot);
|
||||
|
||||
printStatus('');
|
||||
|
||||
@@ -48,6 +48,11 @@ class FlutterCommandRunner extends CommandRunner {
|
||||
negatable: true,
|
||||
hide: !verboseHelp,
|
||||
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',
|
||||
negatable: false,
|
||||
hide: !verboseHelp,
|
||||
@@ -142,7 +147,8 @@ class FlutterCommandRunner extends CommandRunner {
|
||||
// enginePath's initialiser uses it).
|
||||
Cache.flutterRoot = path.normalize(path.absolute(globalResults['flutter-root']));
|
||||
|
||||
await Cache.lock();
|
||||
if (globalResults['lock']);
|
||||
await Cache.lock();
|
||||
|
||||
if (globalResults['suppress-analytics'])
|
||||
flutterUsage.suppressAnalytics = true;
|
||||
|
||||
Reference in New Issue
Block a user