Allowing adding/updating packages during hot reload (#29747)
This commit is contained in:
@@ -481,6 +481,9 @@ class DevFS {
|
||||
outputPath: dillOutputPath ?? getDefaultApplicationKernelPath(trackWidgetCreation: trackWidgetCreation),
|
||||
packagesFilePath : _packagesFilePath,
|
||||
);
|
||||
if (compilerOutput == null) {
|
||||
return UpdateFSReport(success: false);
|
||||
}
|
||||
// list of sources that needs to be monitored are in [compilerOutput.sources]
|
||||
sources = compilerOutput.sources;
|
||||
//
|
||||
|
||||
@@ -317,7 +317,9 @@ class HotRunner extends ResidentRunner {
|
||||
// for all devices should be in sync.
|
||||
final List<Uri> invalidatedFiles = ProjectFileInvalidator.findInvalidated(
|
||||
lastCompiled: flutterDevices[0].devFS.lastCompiled,
|
||||
urisToMonitor: flutterDevices[0].devFS.sources);
|
||||
urisToMonitor: flutterDevices[0].devFS.sources,
|
||||
packagesPath: packagesFilePath,
|
||||
);
|
||||
final UpdateFSReport results = UpdateFSReport(success: true);
|
||||
for (FlutterDevice device in flutterDevices) {
|
||||
results.incorporateResults(await device.updateDevFS(
|
||||
@@ -939,8 +941,11 @@ class ProjectFileInvalidator {
|
||||
static const String _pubCachePathLinuxAndMac = '.pub-cache';
|
||||
static const String _pubCachePathWindows = 'Pub/Cache';
|
||||
|
||||
static List<Uri> findInvalidated({@required DateTime lastCompiled,
|
||||
@required List<Uri> urisToMonitor}) {
|
||||
static List<Uri> findInvalidated({
|
||||
@required DateTime lastCompiled,
|
||||
@required List<Uri> urisToMonitor,
|
||||
@required String packagesPath,
|
||||
}) {
|
||||
final List<Uri> invalidatedFiles = <Uri>[];
|
||||
int scanned = 0;
|
||||
final Stopwatch stopwatch = Stopwatch()..start();
|
||||
@@ -960,6 +965,13 @@ class ProjectFileInvalidator {
|
||||
invalidatedFiles.add(uri);
|
||||
}
|
||||
}
|
||||
// we need to check the .packages file too since it is not used in compilation.
|
||||
final DateTime packagesUpdatedAt = fs.statSync(packagesPath).modified;
|
||||
if (lastCompiled != null && packagesUpdatedAt != null
|
||||
&& packagesUpdatedAt.millisecondsSinceEpoch > lastCompiled.millisecondsSinceEpoch) {
|
||||
invalidatedFiles.add(fs.file(packagesPath).uri);
|
||||
scanned++;
|
||||
}
|
||||
printTrace('Scanned through $scanned files in ${stopwatch.elapsedMilliseconds}ms');
|
||||
return invalidatedFiles;
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ void main() {
|
||||
final MemoryFileSystem memoryFileSystem = MemoryFileSystem();
|
||||
testUsingContext('Empty project', () async {
|
||||
expect(
|
||||
ProjectFileInvalidator.findInvalidated(lastCompiled: DateTime.now(), urisToMonitor: <Uri>[]),
|
||||
ProjectFileInvalidator.findInvalidated(lastCompiled: DateTime.now(), urisToMonitor: <Uri>[], packagesPath: ''),
|
||||
isEmpty);
|
||||
}, overrides: <Type, Generator>{
|
||||
FileSystem: () => memoryFileSystem,
|
||||
@@ -24,7 +24,9 @@ void main() {
|
||||
expect(
|
||||
ProjectFileInvalidator.findInvalidated(
|
||||
lastCompiled: DateTime.now(),
|
||||
urisToMonitor: <Uri>[Uri.parse('/not-there-anymore')]),
|
||||
urisToMonitor: <Uri>[Uri.parse('/not-there-anymore'),],
|
||||
packagesPath: '',
|
||||
),
|
||||
isEmpty);
|
||||
}, overrides: <Type, Generator>{
|
||||
FileSystem: () => memoryFileSystem,
|
||||
|
||||
Reference in New Issue
Block a user