Skip to content

Commit 6c7d642

Browse files
authored
_downloadArtifacts (Web SDK) uses content-aware hashing in post-submit (flutter#174236)
Towards flutter#174225. Will need to get cherry-picked into 3.35 and 3.36.
1 parent a24dbd5 commit 6c7d642

3 files changed

Lines changed: 32 additions & 1 deletion

File tree

engine/src/flutter/lib/web_ui/dev/common.dart

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,31 @@ final String gitRevision = () {
258258
return (result.stdout as String).trim();
259259
}();
260260

261+
final String contentHash = () {
262+
final String executable;
263+
final List<String> args;
264+
if (io.Platform.isWindows) {
265+
executable = 'powershell';
266+
args = <String>[path.join('bin', 'internal', 'content_aware_hash.ps1')];
267+
} else {
268+
executable = path.join('bin', 'internal', 'content_aware_hash.sh');
269+
args = <String>[];
270+
}
271+
final result = io.Process.runSync(
272+
executable,
273+
args,
274+
workingDirectory: environment.flutterRootDir.path,
275+
stderrEncoding: utf8,
276+
stdoutEncoding: utf8,
277+
);
278+
if (result.exitCode != 0) {
279+
throw ToolExit(
280+
'Failed to get content hash. Exit code: ${result.exitCode} Error: ${result.stderr}',
281+
);
282+
}
283+
return (result.stdout as String).trim();
284+
}();
285+
261286
const String kChrome = 'chrome';
262287
const String kEdge = 'edge';
263288
const String kFirefox = 'firefox';

engine/src/flutter/lib/web_ui/dev/environment.dart

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ class Environment {
2424
final io.File self = io.File.fromUri(io.Platform.script);
2525

2626
final io.Directory engineSrcDir = self.parent.parent.parent.parent.parent;
27+
final io.Directory flutterRootDir = engineSrcDir.parent.parent;
2728
final io.Directory engineToolsDir = io.Directory(
2829
pathlib.join(engineSrcDir.path, 'flutter', 'tools'),
2930
);
@@ -52,6 +53,7 @@ class Environment {
5253
isMacosArm: isMacosArm,
5354
webUiRootDir: webUiRootDir,
5455
engineSrcDir: engineSrcDir,
56+
flutterRootDir: flutterRootDir,
5557
engineToolsDir: engineToolsDir,
5658
outDir: outDir,
5759
wasmReleaseOutDir: wasmReleaseOutDir,
@@ -67,6 +69,7 @@ class Environment {
6769
required this.isMacosArm,
6870
required this.webUiRootDir,
6971
required this.engineSrcDir,
72+
required this.flutterRootDir,
7073
required this.engineToolsDir,
7174
required this.outDir,
7275
required this.wasmReleaseOutDir,
@@ -137,6 +140,9 @@ class Environment {
137140
'dart2wasm.dart',
138141
);
139142

143+
/// Path to the root flutter directory (which itself contains `engine/src/flutter`).
144+
final io.Directory flutterRootDir;
145+
140146
/// Path to where github.com/flutter/engine is checked out inside the engine workspace.
141147
io.Directory get flutterDirectory => io.Directory(pathlib.join(engineSrcDir.path, 'flutter'));
142148
io.Directory get webSdkRootDir => io.Directory(pathlib.join(flutterDirectory.path, 'web_sdk'));

engine/src/flutter/lib/web_ui/dev/steps/copy_artifacts_step.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ class CopyArtifactsStep implements PipelineStep {
5757
};
5858
final Uri url = Uri.https(
5959
'storage.googleapis.com',
60-
'${realmComponent}flutter_infra_release/flutter/$gitRevision/flutter-web-sdk.zip',
60+
'${realmComponent}flutter_infra_release/flutter/${realm == LuciRealm.Try ? gitRevision : contentHash}/flutter-web-sdk.zip',
6161
);
6262
final http.Response response = await http.Client().get(url);
6363
if (response.statusCode != 200) {

0 commit comments

Comments
 (0)