Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
5eb4917d
Unverified
Commit
5eb4917d
authored
Jun 09, 2020
by
Jenn Magder
Committed by
GitHub
Jun 09, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Release cache lock for commands after required artifacts are downloaded (#59012)
parent
60cfe495
Changes
25
Hide whitespace changes
Inline
Side-by-side
Showing
25 changed files
with
63 additions
and
56 deletions
+63
-56
cache.dart
packages/flutter_tools/lib/src/cache.dart
+18
-8
analyze_continuously.dart
.../flutter_tools/lib/src/commands/analyze_continuously.dart
+0
-3
analyze_once.dart
packages/flutter_tools/lib/src/commands/analyze_once.dart
+0
-3
attach.dart
packages/flutter_tools/lib/src/commands/attach.dart
+0
-3
build_fuchsia.dart
packages/flutter_tools/lib/src/commands/build_fuchsia.dart
+0
-1
build_ios_framework.dart
...s/flutter_tools/lib/src/commands/build_ios_framework.dart
+0
-2
build_linux.dart
packages/flutter_tools/lib/src/commands/build_linux.dart
+0
-1
build_macos.dart
packages/flutter_tools/lib/src/commands/build_macos.dart
+0
-1
build_windows.dart
packages/flutter_tools/lib/src/commands/build_windows.dart
+0
-1
create.dart
packages/flutter_tools/lib/src/commands/create.dart
+0
-2
daemon.dart
packages/flutter_tools/lib/src/commands/daemon.dart
+0
-2
drive.dart
packages/flutter_tools/lib/src/commands/drive.dart
+0
-3
generate.dart
packages/flutter_tools/lib/src/commands/generate.dart
+0
-2
install.dart
packages/flutter_tools/lib/src/commands/install.dart
+0
-3
logs.dart
packages/flutter_tools/lib/src/commands/logs.dart
+0
-2
packages.dart
packages/flutter_tools/lib/src/commands/packages.dart
+0
-5
precache.dart
packages/flutter_tools/lib/src/commands/precache.dart
+5
-0
run.dart
packages/flutter_tools/lib/src/commands/run.dart
+0
-3
test.dart
packages/flutter_tools/lib/src/commands/test.dart
+0
-3
pub.dart
packages/flutter_tools/lib/src/dart/pub.dart
+0
-1
desktop_device.dart
packages/flutter_tools/lib/src/desktop_device.dart
+0
-2
flutter_command.dart
packages/flutter_tools/lib/src/runner/flutter_command.dart
+5
-1
precache_test.dart
...ter_tools/test/commands.shard/hermetic/precache_test.dart
+32
-1
cache_test.dart
packages/flutter_tools/test/general.shard/cache_test.dart
+2
-2
flutter_command_test.dart
...tools/test/general.shard/runner/flutter_command_test.dart
+1
-1
No files found.
packages/flutter_tools/lib/src/cache.dart
View file @
5eb4917d
...
@@ -166,7 +166,7 @@ class Cache {
...
@@ -166,7 +166,7 @@ class Cache {
static
RandomAccessFile
_lock
;
static
RandomAccessFile
_lock
;
static
bool
_lockEnabled
=
true
;
static
bool
_lockEnabled
=
true
;
/// Turn off the [lock]/[releaseLock
Early
] mechanism.
/// Turn off the [lock]/[releaseLock] mechanism.
///
///
/// This is used by the tests since they run simultaneously and all in one
/// This is used by the tests since they run simultaneously and all in one
/// process and so it would be a mess if they had to use the lock.
/// process and so it would be a mess if they had to use the lock.
...
@@ -175,7 +175,7 @@ class Cache {
...
@@ -175,7 +175,7 @@ class Cache {
_lockEnabled
=
false
;
_lockEnabled
=
false
;
}
}
/// Turn on the [lock]/[releaseLock
Early
] mechanism.
/// Turn on the [lock]/[releaseLock] mechanism.
///
///
/// This is used by the tests.
/// This is used by the tests.
@visibleForTesting
@visibleForTesting
...
@@ -183,13 +183,20 @@ class Cache {
...
@@ -183,13 +183,20 @@ class Cache {
_lockEnabled
=
true
;
_lockEnabled
=
true
;
}
}
/// Check if lock acquired, skipping FLUTTER_ALREADY_LOCKED reentrant checks.
///
/// This is used by the tests.
@visibleForTesting
static
bool
isLocked
()
{
return
_lock
!=
null
;
}
/// Lock the cache directory.
/// Lock the cache directory.
///
///
/// This happens automatically on startup (see [FlutterCommandRunner.runCommand]).
/// This happens while required artifacts are updated
/// (see [FlutterCommandRunner.runCommand]).
///
///
/// Normally the lock will be held until the process exits (this uses normal
/// This uses normal POSIX flock semantics.
/// POSIX flock semantics). Long-lived commands should release the lock by
/// calling [Cache.releaseLockEarly] once they are no longer touching the cache.
static
Future
<
void
>
lock
()
async
{
static
Future
<
void
>
lock
()
async
{
if
(!
_lockEnabled
)
{
if
(!
_lockEnabled
)
{
return
;
return
;
...
@@ -222,8 +229,11 @@ class Cache {
...
@@ -222,8 +229,11 @@ class Cache {
}
}
}
}
/// Releases the lock. This is not necessary unless the process is long-lived.
/// Releases the lock.
static
void
releaseLockEarly
()
{
///
/// This happens automatically on startup (see [FlutterCommand.verifyThenRunCommand])
/// after the command's required artifacts are updated.
static
void
releaseLock
()
{
if
(!
_lockEnabled
||
_lock
==
null
)
{
if
(!
_lockEnabled
||
_lock
==
null
)
{
return
;
return
;
}
}
...
...
packages/flutter_tools/lib/src/commands/analyze_continuously.dart
View file @
5eb4917d
...
@@ -15,7 +15,6 @@ import '../base/logger.dart';
...
@@ -15,7 +15,6 @@ import '../base/logger.dart';
import
'../base/platform.dart'
;
import
'../base/platform.dart'
;
import
'../base/terminal.dart'
;
import
'../base/terminal.dart'
;
import
'../base/utils.dart'
;
import
'../base/utils.dart'
;
import
'../cache.dart'
;
import
'../dart/analysis.dart'
;
import
'../dart/analysis.dart'
;
import
'../dart/sdk.dart'
as
sdk
;
import
'../dart/sdk.dart'
as
sdk
;
import
'analyze_base.dart'
;
import
'analyze_base.dart'
;
...
@@ -81,8 +80,6 @@ class AnalyzeContinuously extends AnalyzeBase {
...
@@ -81,8 +80,6 @@ class AnalyzeContinuously extends AnalyzeBase {
server
.
onAnalyzing
.
listen
((
bool
isAnalyzing
)
=>
_handleAnalysisStatus
(
server
,
isAnalyzing
));
server
.
onAnalyzing
.
listen
((
bool
isAnalyzing
)
=>
_handleAnalysisStatus
(
server
,
isAnalyzing
));
server
.
onErrors
.
listen
(
_handleAnalysisErrors
);
server
.
onErrors
.
listen
(
_handleAnalysisErrors
);
Cache
.
releaseLockEarly
();
await
server
.
start
();
await
server
.
start
();
final
int
exitCode
=
await
server
.
onExit
;
final
int
exitCode
=
await
server
.
onExit
;
...
...
packages/flutter_tools/lib/src/commands/analyze_once.dart
View file @
5eb4917d
...
@@ -14,7 +14,6 @@ import '../base/logger.dart';
...
@@ -14,7 +14,6 @@ import '../base/logger.dart';
import
'../base/platform.dart'
;
import
'../base/platform.dart'
;
import
'../base/terminal.dart'
;
import
'../base/terminal.dart'
;
import
'../base/utils.dart'
;
import
'../base/utils.dart'
;
import
'../cache.dart'
;
import
'../dart/analysis.dart'
;
import
'../dart/analysis.dart'
;
import
'../dart/sdk.dart'
as
sdk
;
import
'../dart/sdk.dart'
as
sdk
;
import
'analyze.dart'
;
import
'analyze.dart'
;
...
@@ -127,8 +126,6 @@ class AnalyzeOnce extends AnalyzeBase {
...
@@ -127,8 +126,6 @@ class AnalyzeOnce extends AnalyzeBase {
}
}
}));
}));
Cache
.
releaseLockEarly
();
// collect results
// collect results
timer
=
Stopwatch
()..
start
();
timer
=
Stopwatch
()..
start
();
final
String
message
=
directories
.
length
>
1
final
String
message
=
directories
.
length
>
1
...
...
packages/flutter_tools/lib/src/commands/attach.dart
View file @
5eb4917d
...
@@ -12,7 +12,6 @@ import '../base/common.dart';
...
@@ -12,7 +12,6 @@ import '../base/common.dart';
import
'../base/context.dart'
;
import
'../base/context.dart'
;
import
'../base/file_system.dart'
;
import
'../base/file_system.dart'
;
import
'../base/io.dart'
;
import
'../base/io.dart'
;
import
'../cache.dart'
;
import
'../commands/daemon.dart'
;
import
'../commands/daemon.dart'
;
import
'../compile.dart'
;
import
'../compile.dart'
;
import
'../device.dart'
;
import
'../device.dart'
;
...
@@ -173,8 +172,6 @@ class AttachCommand extends FlutterCommand {
...
@@ -173,8 +172,6 @@ class AttachCommand extends FlutterCommand {
@override
@override
Future
<
FlutterCommandResult
>
runCommand
()
async
{
Future
<
FlutterCommandResult
>
runCommand
()
async
{
Cache
.
releaseLockEarly
();
await
_validateArguments
();
await
_validateArguments
();
writePidFile
(
stringArg
(
'pid-file'
));
writePidFile
(
stringArg
(
'pid-file'
));
...
...
packages/flutter_tools/lib/src/commands/build_fuchsia.dart
View file @
5eb4917d
...
@@ -56,7 +56,6 @@ class BuildFuchsiaCommand extends BuildSubCommand {
...
@@ -56,7 +56,6 @@ class BuildFuchsiaCommand extends BuildSubCommand {
@override
@override
Future
<
FlutterCommandResult
>
runCommand
()
async
{
Future
<
FlutterCommandResult
>
runCommand
()
async
{
Cache
.
releaseLockEarly
();
final
BuildInfo
buildInfo
=
getBuildInfo
();
final
BuildInfo
buildInfo
=
getBuildInfo
();
final
FlutterProject
flutterProject
=
FlutterProject
.
current
();
final
FlutterProject
flutterProject
=
FlutterProject
.
current
();
if
(!
globals
.
platform
.
isLinux
&&
!
globals
.
platform
.
isMacOS
)
{
if
(!
globals
.
platform
.
isLinux
&&
!
globals
.
platform
.
isMacOS
)
{
...
...
packages/flutter_tools/lib/src/commands/build_ios_framework.dart
View file @
5eb4917d
...
@@ -166,8 +166,6 @@ class BuildIOSFrameworkCommand extends BuildSubCommand {
...
@@ -166,8 +166,6 @@ class BuildIOSFrameworkCommand extends BuildSubCommand {
@override
@override
Future
<
FlutterCommandResult
>
runCommand
()
async
{
Future
<
FlutterCommandResult
>
runCommand
()
async
{
Cache
.
releaseLockEarly
();
final
String
outputArgument
=
stringArg
(
'output'
)
final
String
outputArgument
=
stringArg
(
'output'
)
??
globals
.
fs
.
path
.
join
(
globals
.
fs
.
currentDirectory
.
path
,
'build'
,
'ios'
,
'framework'
);
??
globals
.
fs
.
path
.
join
(
globals
.
fs
.
currentDirectory
.
path
,
'build'
,
'ios'
,
'framework'
);
...
...
packages/flutter_tools/lib/src/commands/build_linux.dart
View file @
5eb4917d
...
@@ -47,7 +47,6 @@ class BuildLinuxCommand extends BuildSubCommand {
...
@@ -47,7 +47,6 @@ class BuildLinuxCommand extends BuildSubCommand {
@override
@override
Future
<
FlutterCommandResult
>
runCommand
()
async
{
Future
<
FlutterCommandResult
>
runCommand
()
async
{
Cache
.
releaseLockEarly
();
final
BuildInfo
buildInfo
=
getBuildInfo
();
final
BuildInfo
buildInfo
=
getBuildInfo
();
final
FlutterProject
flutterProject
=
FlutterProject
.
current
();
final
FlutterProject
flutterProject
=
FlutterProject
.
current
();
if
(!
featureFlags
.
isLinuxEnabled
)
{
if
(!
featureFlags
.
isLinuxEnabled
)
{
...
...
packages/flutter_tools/lib/src/commands/build_macos.dart
View file @
5eb4917d
...
@@ -48,7 +48,6 @@ class BuildMacosCommand extends BuildSubCommand {
...
@@ -48,7 +48,6 @@ class BuildMacosCommand extends BuildSubCommand {
@override
@override
Future
<
FlutterCommandResult
>
runCommand
()
async
{
Future
<
FlutterCommandResult
>
runCommand
()
async
{
Cache
.
releaseLockEarly
();
final
BuildInfo
buildInfo
=
getBuildInfo
();
final
BuildInfo
buildInfo
=
getBuildInfo
();
final
FlutterProject
flutterProject
=
FlutterProject
.
current
();
final
FlutterProject
flutterProject
=
FlutterProject
.
current
();
if
(!
featureFlags
.
isMacOSEnabled
)
{
if
(!
featureFlags
.
isMacOSEnabled
)
{
...
...
packages/flutter_tools/lib/src/commands/build_windows.dart
View file @
5eb4917d
...
@@ -52,7 +52,6 @@ class BuildWindowsCommand extends BuildSubCommand {
...
@@ -52,7 +52,6 @@ class BuildWindowsCommand extends BuildSubCommand {
@override
@override
Future
<
FlutterCommandResult
>
runCommand
()
async
{
Future
<
FlutterCommandResult
>
runCommand
()
async
{
Cache
.
releaseLockEarly
();
final
FlutterProject
flutterProject
=
FlutterProject
.
current
();
final
FlutterProject
flutterProject
=
FlutterProject
.
current
();
final
BuildInfo
buildInfo
=
getBuildInfo
();
final
BuildInfo
buildInfo
=
getBuildInfo
();
if
(!
featureFlags
.
isWindowsEnabled
)
{
if
(!
featureFlags
.
isWindowsEnabled
)
{
...
...
packages/flutter_tools/lib/src/commands/create.dart
View file @
5eb4917d
...
@@ -262,8 +262,6 @@ class CreateCommand extends FlutterCommand {
...
@@ -262,8 +262,6 @@ class CreateCommand extends FlutterCommand {
Future
<
FlutterCommandResult
>
runCommand
()
async
{
Future
<
FlutterCommandResult
>
runCommand
()
async
{
if
(
argResults
[
'list-samples'
]
!=
null
)
{
if
(
argResults
[
'list-samples'
]
!=
null
)
{
// _writeSamplesJson can potentially be long-lived.
// _writeSamplesJson can potentially be long-lived.
Cache
.
releaseLockEarly
();
await
_writeSamplesJson
(
stringArg
(
'list-samples'
));
await
_writeSamplesJson
(
stringArg
(
'list-samples'
));
return
FlutterCommandResult
.
success
();
return
FlutterCommandResult
.
success
();
}
}
...
...
packages/flutter_tools/lib/src/commands/daemon.dart
View file @
5eb4917d
...
@@ -16,7 +16,6 @@ import '../base/logger.dart';
...
@@ -16,7 +16,6 @@ import '../base/logger.dart';
import
'../base/terminal.dart'
;
import
'../base/terminal.dart'
;
import
'../base/utils.dart'
;
import
'../base/utils.dart'
;
import
'../build_info.dart'
;
import
'../build_info.dart'
;
import
'../cache.dart'
;
import
'../convert.dart'
;
import
'../convert.dart'
;
import
'../device.dart'
;
import
'../device.dart'
;
import
'../emulator.dart'
;
import
'../emulator.dart'
;
...
@@ -52,7 +51,6 @@ class DaemonCommand extends FlutterCommand {
...
@@ -52,7 +51,6 @@ class DaemonCommand extends FlutterCommand {
Future
<
FlutterCommandResult
>
runCommand
()
async
{
Future
<
FlutterCommandResult
>
runCommand
()
async
{
globals
.
printStatus
(
'Starting device daemon...'
);
globals
.
printStatus
(
'Starting device daemon...'
);
isRunningFromDaemon
=
true
;
isRunningFromDaemon
=
true
;
Cache
.
releaseLockEarly
();
final
Daemon
daemon
=
Daemon
(
final
Daemon
daemon
=
Daemon
(
stdinCommandStream
,
stdoutCommandResponse
,
stdinCommandStream
,
stdoutCommandResponse
,
...
...
packages/flutter_tools/lib/src/commands/drive.dart
View file @
5eb4917d
...
@@ -16,7 +16,6 @@ import '../base/common.dart';
...
@@ -16,7 +16,6 @@ import '../base/common.dart';
import
'../base/file_system.dart'
;
import
'../base/file_system.dart'
;
import
'../base/process.dart'
;
import
'../base/process.dart'
;
import
'../build_info.dart'
;
import
'../build_info.dart'
;
import
'../cache.dart'
;
import
'../dart/package_map.dart'
;
import
'../dart/package_map.dart'
;
import
'../dart/sdk.dart'
;
import
'../dart/sdk.dart'
;
import
'../device.dart'
;
import
'../device.dart'
;
...
@@ -250,8 +249,6 @@ class DriveCommand extends RunCommandBase {
...
@@ -250,8 +249,6 @@ class DriveCommand extends RunCommandBase {
observatoryUri
=
stringArg
(
'use-existing-app'
);
observatoryUri
=
stringArg
(
'use-existing-app'
);
}
}
Cache
.
releaseLockEarly
();
final
Map
<
String
,
String
>
environment
=
<
String
,
String
>{
final
Map
<
String
,
String
>
environment
=
<
String
,
String
>{
'VM_SERVICE_URL'
:
observatoryUri
,
'VM_SERVICE_URL'
:
observatoryUri
,
};
};
...
...
packages/flutter_tools/lib/src/commands/generate.dart
View file @
5eb4917d
...
@@ -3,7 +3,6 @@
...
@@ -3,7 +3,6 @@
// found in the LICENSE file.
// found in the LICENSE file.
import
'../base/file_system.dart'
;
import
'../base/file_system.dart'
;
import
'../cache.dart'
;
import
'../codegen.dart'
;
import
'../codegen.dart'
;
import
'../convert.dart'
;
import
'../convert.dart'
;
import
'../globals.dart'
as
globals
;
import
'../globals.dart'
as
globals
;
...
@@ -25,7 +24,6 @@ class GenerateCommand extends FlutterCommand {
...
@@ -25,7 +24,6 @@ class GenerateCommand extends FlutterCommand {
@override
@override
Future
<
FlutterCommandResult
>
runCommand
()
async
{
Future
<
FlutterCommandResult
>
runCommand
()
async
{
Cache
.
releaseLockEarly
();
final
FlutterProject
flutterProject
=
FlutterProject
.
current
();
final
FlutterProject
flutterProject
=
FlutterProject
.
current
();
globals
.
printError
(<
String
>[
globals
.
printError
(<
String
>[
'"flutter generate" is deprecated, use "dart pub run build_runner" instead. '
,
'"flutter generate" is deprecated, use "dart pub run build_runner" instead. '
,
...
...
packages/flutter_tools/lib/src/commands/install.dart
View file @
5eb4917d
...
@@ -8,7 +8,6 @@ import '../android/android_device.dart';
...
@@ -8,7 +8,6 @@ import '../android/android_device.dart';
import
'../application_package.dart'
;
import
'../application_package.dart'
;
import
'../base/common.dart'
;
import
'../base/common.dart'
;
import
'../base/io.dart'
;
import
'../base/io.dart'
;
import
'../cache.dart'
;
import
'../device.dart'
;
import
'../device.dart'
;
import
'../globals.dart'
as
globals
;
import
'../globals.dart'
as
globals
;
import
'../runner/flutter_command.dart'
;
import
'../runner/flutter_command.dart'
;
...
@@ -54,8 +53,6 @@ class InstallCommand extends FlutterCommand with DeviceBasedDevelopmentArtifacts
...
@@ -54,8 +53,6 @@ class InstallCommand extends FlutterCommand with DeviceBasedDevelopmentArtifacts
null
,
// Build info isn't relevant for install, will use whatever bundle was built last.
null
,
// Build info isn't relevant for install, will use whatever bundle was built last.
);
);
Cache
.
releaseLockEarly
();
if
(
uninstallOnly
)
{
if
(
uninstallOnly
)
{
await
_uninstallApp
(
package
);
await
_uninstallApp
(
package
);
}
else
{
}
else
{
...
...
packages/flutter_tools/lib/src/commands/logs.dart
View file @
5eb4917d
...
@@ -48,8 +48,6 @@ class LogsCommand extends FlutterCommand {
...
@@ -48,8 +48,6 @@ class LogsCommand extends FlutterCommand {
final
DeviceLogReader
logReader
=
await
device
.
getLogReader
();
final
DeviceLogReader
logReader
=
await
device
.
getLogReader
();
Cache
.
releaseLockEarly
();
globals
.
printStatus
(
'Showing
$logReader
logs:'
);
globals
.
printStatus
(
'Showing
$logReader
logs:'
);
final
Completer
<
int
>
exitCompleter
=
Completer
<
int
>();
final
Completer
<
int
>
exitCompleter
=
Completer
<
int
>();
...
...
packages/flutter_tools/lib/src/commands/packages.dart
View file @
5eb4917d
...
@@ -6,7 +6,6 @@ import 'dart:async';
...
@@ -6,7 +6,6 @@ import 'dart:async';
import
'../base/common.dart'
;
import
'../base/common.dart'
;
import
'../base/os.dart'
;
import
'../base/os.dart'
;
import
'../cache.dart'
;
import
'../dart/pub.dart'
;
import
'../dart/pub.dart'
;
import
'../globals.dart'
as
globals
;
import
'../globals.dart'
as
globals
;
import
'../project.dart'
;
import
'../project.dart'
;
...
@@ -163,7 +162,6 @@ class PackagesTestCommand extends FlutterCommand {
...
@@ -163,7 +162,6 @@ class PackagesTestCommand extends FlutterCommand {
@override
@override
Future
<
FlutterCommandResult
>
runCommand
()
async
{
Future
<
FlutterCommandResult
>
runCommand
()
async
{
Cache
.
releaseLockEarly
();
await
pub
.
batch
(<
String
>[
'run'
,
'test'
,
...
argResults
.
rest
],
context:
PubContext
.
runTest
,
retry:
false
);
await
pub
.
batch
(<
String
>[
'run'
,
'test'
,
...
argResults
.
rest
],
context:
PubContext
.
runTest
,
retry:
false
);
return
FlutterCommandResult
.
success
();
return
FlutterCommandResult
.
success
();
}
}
...
@@ -204,7 +202,6 @@ class PackagesPublishCommand extends FlutterCommand {
...
@@ -204,7 +202,6 @@ class PackagesPublishCommand extends FlutterCommand {
if
(
boolArg
(
'dry-run'
))
'--dry-run'
,
if
(
boolArg
(
'dry-run'
))
'--dry-run'
,
if
(
boolArg
(
'force'
))
'--force'
,
if
(
boolArg
(
'force'
))
'--force'
,
];
];
Cache
.
releaseLockEarly
();
await
pub
.
interactively
(<
String
>[
'publish'
,
...
args
],
stdio:
globals
.
stdio
);
await
pub
.
interactively
(<
String
>[
'publish'
,
...
args
],
stdio:
globals
.
stdio
);
return
FlutterCommandResult
.
success
();
return
FlutterCommandResult
.
success
();
}
}
...
@@ -235,7 +232,6 @@ class PackagesForwardCommand extends FlutterCommand {
...
@@ -235,7 +232,6 @@ class PackagesForwardCommand extends FlutterCommand {
@override
@override
Future
<
FlutterCommandResult
>
runCommand
()
async
{
Future
<
FlutterCommandResult
>
runCommand
()
async
{
Cache
.
releaseLockEarly
();
await
pub
.
interactively
(<
String
>[
_commandName
,
...
argResults
.
rest
],
stdio:
globals
.
stdio
);
await
pub
.
interactively
(<
String
>[
_commandName
,
...
argResults
.
rest
],
stdio:
globals
.
stdio
);
return
FlutterCommandResult
.
success
();
return
FlutterCommandResult
.
success
();
}
}
...
@@ -263,7 +259,6 @@ class PackagesPassthroughCommand extends FlutterCommand {
...
@@ -263,7 +259,6 @@ class PackagesPassthroughCommand extends FlutterCommand {
@override
@override
Future
<
FlutterCommandResult
>
runCommand
()
async
{
Future
<
FlutterCommandResult
>
runCommand
()
async
{
Cache
.
releaseLockEarly
();
await
pub
.
interactively
(
argResults
.
rest
,
stdio:
globals
.
stdio
);
await
pub
.
interactively
(
argResults
.
rest
,
stdio:
globals
.
stdio
);
return
FlutterCommandResult
.
success
();
return
FlutterCommandResult
.
success
();
}
}
...
...
packages/flutter_tools/lib/src/commands/precache.dart
View file @
5eb4917d
...
@@ -111,6 +111,11 @@ class PrecacheCommand extends FlutterCommand {
...
@@ -111,6 +111,11 @@ class PrecacheCommand extends FlutterCommand {
@override
@override
Future
<
FlutterCommandResult
>
runCommand
()
async
{
Future
<
FlutterCommandResult
>
runCommand
()
async
{
// Re-lock the cache.
if
(
globals
.
platform
.
environment
[
'FLUTTER_ALREADY_LOCKED'
]
!=
'true'
)
{
await
Cache
.
lock
();
}
final
bool
includeAllPlatforms
=
boolArg
(
'all-platforms'
);
final
bool
includeAllPlatforms
=
boolArg
(
'all-platforms'
);
if
(
includeAllPlatforms
)
{
if
(
includeAllPlatforms
)
{
globals
.
cache
.
includeAllPlatforms
=
true
;
globals
.
cache
.
includeAllPlatforms
=
true
;
...
...
packages/flutter_tools/lib/src/commands/run.dart
View file @
5eb4917d
...
@@ -12,7 +12,6 @@ import '../base/file_system.dart';
...
@@ -12,7 +12,6 @@ import '../base/file_system.dart';
import
'../base/io.dart'
;
import
'../base/io.dart'
;
import
'../base/utils.dart'
;
import
'../base/utils.dart'
;
import
'../build_info.dart'
;
import
'../build_info.dart'
;
import
'../cache.dart'
;
import
'../device.dart'
;
import
'../device.dart'
;
import
'../features.dart'
;
import
'../features.dart'
;
import
'../globals.dart'
as
globals
;
import
'../globals.dart'
as
globals
;
...
@@ -403,8 +402,6 @@ class RunCommand extends RunCommandBase {
...
@@ -403,8 +402,6 @@ class RunCommand extends RunCommandBase {
@override
@override
Future
<
FlutterCommandResult
>
runCommand
()
async
{
Future
<
FlutterCommandResult
>
runCommand
()
async
{
Cache
.
releaseLockEarly
();
// Enable hot mode by default if `--no-hot` was not passed and we are in
// Enable hot mode by default if `--no-hot` was not passed and we are in
// debug mode.
// debug mode.
final
bool
hotMode
=
shouldUseHotMode
();
final
bool
hotMode
=
shouldUseHotMode
();
...
...
packages/flutter_tools/lib/src/commands/test.dart
View file @
5eb4917d
...
@@ -156,7 +156,6 @@ class TestCommand extends FlutterCommand {
...
@@ -156,7 +156,6 @@ class TestCommand extends FlutterCommand {
@override
@override
Future
<
FlutterCommandResult
>
runCommand
()
async
{
Future
<
FlutterCommandResult
>
runCommand
()
async
{
await
globals
.
cache
.
updateAll
(
await
requiredArtifacts
);
if
(!
globals
.
fs
.
isFileSync
(
'pubspec.yaml'
))
{
if
(!
globals
.
fs
.
isFileSync
(
'pubspec.yaml'
))
{
throwToolExit
(
throwToolExit
(
'Error: No pubspec.yaml file found in the current working directory.
\n
'
'Error: No pubspec.yaml file found in the current working directory.
\n
'
...
@@ -237,8 +236,6 @@ class TestCommand extends FlutterCommand {
...
@@ -237,8 +236,6 @@ class TestCommand extends FlutterCommand {
watcher
=
collector
;
watcher
=
collector
;
}
}
Cache
.
releaseLockEarly
();
// Run builders once before all tests.
// Run builders once before all tests.
if
(
flutterProject
.
hasBuilders
)
{
if
(
flutterProject
.
hasBuilders
)
{
final
CodegenDaemon
codegenDaemon
=
await
codeGenerator
.
daemon
(
flutterProject
);
final
CodegenDaemon
codegenDaemon
=
await
codeGenerator
.
daemon
(
flutterProject
);
...
...
packages/flutter_tools/lib/src/dart/pub.dart
View file @
5eb4917d
...
@@ -328,7 +328,6 @@ class _DefaultPub implements Pub {
...
@@ -328,7 +328,6 @@ class _DefaultPub implements Pub {
String
directory
,
String
directory
,
@required
io
.
Stdio
stdio
,
@required
io
.
Stdio
stdio
,
})
async
{
})
async
{
Cache
.
releaseLockEarly
();
final
io
.
Process
process
=
await
_processUtils
.
start
(
final
io
.
Process
process
=
await
_processUtils
.
start
(
_pubCommand
(
arguments
),
_pubCommand
(
arguments
),
workingDirectory:
directory
,
workingDirectory:
directory
,
...
...
packages/flutter_tools/lib/src/desktop_device.dart
View file @
5eb4917d
...
@@ -10,7 +10,6 @@ import 'application_package.dart';
...
@@ -10,7 +10,6 @@ import 'application_package.dart';
import
'base/common.dart'
;
import
'base/common.dart'
;
import
'base/io.dart'
;
import
'base/io.dart'
;
import
'build_info.dart'
;
import
'build_info.dart'
;
import
'cache.dart'
;
import
'convert.dart'
;
import
'convert.dart'
;
import
'device.dart'
;
import
'device.dart'
;
import
'globals.dart'
as
globals
;
import
'globals.dart'
as
globals
;
...
@@ -98,7 +97,6 @@ abstract class DesktopDevice extends Device {
...
@@ -98,7 +97,6 @@ abstract class DesktopDevice extends Device {
String
userIdentifier
,
String
userIdentifier
,
})
async
{
})
async
{
if
(!
prebuiltApplication
)
{
if
(!
prebuiltApplication
)
{
Cache
.
releaseLockEarly
();
await
buildForDevice
(
await
buildForDevice
(
package
,
package
,
buildInfo:
debuggingOptions
?.
buildInfo
,
buildInfo:
debuggingOptions
?.
buildInfo
,
...
...
packages/flutter_tools/lib/src/runner/flutter_command.dart
View file @
5eb4917d
...
@@ -731,7 +731,7 @@ abstract class FlutterCommand extends Command<void> {
...
@@ -731,7 +731,7 @@ abstract class FlutterCommand extends Command<void> {
void
_registerSignalHandlers
(
String
commandPath
,
DateTime
startTime
)
{
void
_registerSignalHandlers
(
String
commandPath
,
DateTime
startTime
)
{
final
SignalHandler
handler
=
(
io
.
ProcessSignal
s
)
{
final
SignalHandler
handler
=
(
io
.
ProcessSignal
s
)
{
Cache
.
releaseLock
Early
();
Cache
.
releaseLock
();
_sendPostUsage
(
_sendPostUsage
(
commandPath
,
commandPath
,
const
FlutterCommandResult
(
ExitStatus
.
killed
),
const
FlutterCommandResult
(
ExitStatus
.
killed
),
...
@@ -806,8 +806,12 @@ abstract class FlutterCommand extends Command<void> {
...
@@ -806,8 +806,12 @@ abstract class FlutterCommand extends Command<void> {
if
(
shouldRunPub
)
{
if
(
shouldRunPub
)
{
await
pub
.
get
(
context:
PubContext
.
getVerifyContext
(
name
));
await
pub
.
get
(
context:
PubContext
.
getVerifyContext
(
name
));
// All done updating dependencies. Release the cache lock.
Cache
.
releaseLock
();
final
FlutterProject
project
=
FlutterProject
.
current
();
final
FlutterProject
project
=
FlutterProject
.
current
();
await
project
.
ensureReadyForPlatformSpecificTooling
(
checkProjects:
true
);
await
project
.
ensureReadyForPlatformSpecificTooling
(
checkProjects:
true
);
}
else
{
Cache
.
releaseLock
();
}
}
setupApplicationPackages
();
setupApplicationPackages
();
...
...
packages/flutter_tools/test/commands.shard/hermetic/precache_test.dart
View file @
5eb4917d
...
@@ -24,7 +24,7 @@ void main() {
...
@@ -24,7 +24,7 @@ void main() {
setUp
(()
{
setUp
(()
{
cache
=
MockCache
();
cache
=
MockCache
();
// Release lock between test cases.
// Release lock between test cases.
Cache
.
releaseLock
Early
();
Cache
.
releaseLock
();
when
(
cache
.
isUpToDate
()).
thenReturn
(
false
);
when
(
cache
.
isUpToDate
()).
thenReturn
(
false
);
when
(
cache
.
updateAll
(
any
)).
thenAnswer
((
Invocation
invocation
)
{
when
(
cache
.
updateAll
(
any
)).
thenAnswer
((
Invocation
invocation
)
{
...
@@ -37,6 +37,37 @@ void main() {
...
@@ -37,6 +37,37 @@ void main() {
when
(
masterFlutterVersion
.
isMaster
).
thenReturn
(
true
);
when
(
masterFlutterVersion
.
isMaster
).
thenReturn
(
true
);
});
});
testUsingContext
(
'precache should acquire lock'
,
()
async
{
final
PrecacheCommand
command
=
PrecacheCommand
();
applyMocksToCommand
(
command
);
await
createTestCommandRunner
(
command
).
run
(
const
<
String
>[
'precache'
]);
expect
(
Cache
.
isLocked
(),
isTrue
);
// Do not throw StateError, lock is acquired.
Cache
.
checkLockAcquired
();
},
overrides:
<
Type
,
Generator
>{
Cache:
()
=>
cache
,
});
testUsingContext
(
'precache should not re-entrantly acquire lock'
,
()
async
{
final
PrecacheCommand
command
=
PrecacheCommand
();
applyMocksToCommand
(
command
);
await
createTestCommandRunner
(
command
).
run
(
const
<
String
>[
'precache'
]);
expect
(
Cache
.
isLocked
(),
isFalse
);
// Do not throw StateError, acquired reentrantly with FLUTTER_ALREADY_LOCKED.
Cache
.
checkLockAcquired
();
},
overrides:
<
Type
,
Generator
>{
Cache:
()
=>
cache
,
Platform:
()
=>
FakePlatform
(
operatingSystem:
'windows'
,
environment:
<
String
,
String
>{
'FLUTTER_ROOT'
:
'flutter'
,
'FLUTTER_ALREADY_LOCKED'
:
'true'
,
},
),
});
testUsingContext
(
'precache downloads web artifacts on dev branch when feature is enabled.'
,
()
async
{
testUsingContext
(
'precache downloads web artifacts on dev branch when feature is enabled.'
,
()
async
{
final
PrecacheCommand
command
=
PrecacheCommand
();
final
PrecacheCommand
command
=
PrecacheCommand
();
applyMocksToCommand
(
command
);
applyMocksToCommand
(
command
);
...
...
packages/flutter_tools/test/general.shard/cache_test.dart
View file @
5eb4917d
...
@@ -43,7 +43,7 @@ void main() {
...
@@ -43,7 +43,7 @@ void main() {
// Restore locking to prevent potential side-effects in
// Restore locking to prevent potential side-effects in
// tests outside this group (this option is globally shared).
// tests outside this group (this option is globally shared).
Cache
.
enableLocking
();
Cache
.
enableLocking
();
Cache
.
releaseLock
Early
();
Cache
.
releaseLock
();
});
});
test
(
'should throw when locking is not acquired'
,
()
{
test
(
'should throw when locking is not acquired'
,
()
{
...
@@ -60,7 +60,7 @@ void main() {
...
@@ -60,7 +60,7 @@ void main() {
when
(
mockFile
.
openSync
(
mode:
anyNamed
(
'mode'
))).
thenReturn
(
mockRandomAccessFile
);
when
(
mockFile
.
openSync
(
mode:
anyNamed
(
'mode'
))).
thenReturn
(
mockRandomAccessFile
);
await
Cache
.
lock
();
await
Cache
.
lock
();
Cache
.
checkLockAcquired
();
Cache
.
checkLockAcquired
();
Cache
.
releaseLock
Early
();
Cache
.
releaseLock
();
},
overrides:
<
Type
,
Generator
>{
},
overrides:
<
Type
,
Generator
>{
FileSystem:
()
=>
mockFileSystem
,
FileSystem:
()
=>
mockFileSystem
,
ProcessManager:
()
=>
FakeProcessManager
.
any
(),
ProcessManager:
()
=>
FakeProcessManager
.
any
(),
...
...
packages/flutter_tools/test/general.shard/runner/flutter_command_test.dart
View file @
5eb4917d
...
@@ -321,7 +321,7 @@ void main() {
...
@@ -321,7 +321,7 @@ void main() {
await
completer
.
future
;
await
completer
.
future
;
await
Cache
.
lock
();
await
Cache
.
lock
();
Cache
.
releaseLock
Early
();
Cache
.
releaseLock
();
},
overrides:
<
Type
,
Generator
>{
},
overrides:
<
Type
,
Generator
>{
ProcessInfo:
()
=>
mockProcessInfo
,
ProcessInfo:
()
=>
mockProcessInfo
,
Signals:
()
=>
FakeSignals
(
Signals:
()
=>
FakeSignals
(
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment