Unverified Commit 61291aee authored by Jonah Williams's avatar Jonah Williams Committed by GitHub

ensure lastBuildTimestamp is set before early return (#25058)

parent 243222c0
...@@ -107,6 +107,10 @@ class _ManifestAssetBundle implements AssetBundle { ...@@ -107,6 +107,10 @@ class _ManifestAssetBundle implements AssetBundle {
if (flutterManifest == null) if (flutterManifest == null)
return 1; return 1;
// If the last build time isn't set before this early return, empty pubspecs will
// hang on hot reload, as the incremental dill files will never be copied to the
// device.
_lastBuildTimestamp = DateTime.now();
if (flutterManifest.isEmpty) { if (flutterManifest.isEmpty) {
entries[_assetManifestJson] = DevFSStringContent('{}'); entries[_assetManifestJson] = DevFSStringContent('{}');
return 0; return 0;
...@@ -114,8 +118,6 @@ class _ManifestAssetBundle implements AssetBundle { ...@@ -114,8 +118,6 @@ class _ManifestAssetBundle implements AssetBundle {
final String assetBasePath = fs.path.dirname(fs.path.absolute(manifestPath)); final String assetBasePath = fs.path.dirname(fs.path.absolute(manifestPath));
_lastBuildTimestamp = DateTime.now();
final PackageMap packageMap = PackageMap(packagesPath); final PackageMap packageMap = PackageMap(packagesPath);
// The _assetVariants map contains an entry for each asset listed // The _assetVariants map contains an entry for each asset listed
......
...@@ -41,8 +41,26 @@ void main() { ...@@ -41,8 +41,26 @@ void main() {
await getValueAsString('FontManifest.json', asset), await getValueAsString('FontManifest.json', asset),
'[{"family":"packages/font/test_font","fonts":[{"asset":"packages/font/test_font_file"}]}]', '[{"family":"packages/font/test_font","fonts":[{"asset":"packages/font/test_font_file"}]}]',
); );
expect(asset.wasBuiltOnce(), true);
}); });
testUsingContext('handles empty pubspec with .packages', () async {
final String dataPath = fs.path.join(
getFlutterRoot(),
'packages',
'flutter_tools',
'test',
'data',
'fuchsia_test',
);
final AssetBundle asset = AssetBundleFactory.instance.createBundle();
await asset.build(
manifestPath : fs.path.join(dataPath, 'main', 'pubspec.yaml'), // file doesn't exist
packagesPath: fs.path.join(dataPath, 'main', '.packages'),
includeDefaultFonts: false,
);
expect(asset.wasBuiltOnce(), 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