Skip to content

Commit

Permalink
Skip delete for SDK summary and deps file (#3573)
Browse files Browse the repository at this point in the history
Fixes #2995

When the summary file is determined to be invalid, regenerate it and
overwrite it without deleting. This resolves a race condition where
multiple resolvers could try to delete the same file. The invalid
content will not be read, because we will regenerate the file before
moving on to the rest of the build.
  • Loading branch information
natebosch committed Sep 6, 2023
1 parent 9fa21b9 commit a161297
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 12 deletions.
6 changes: 6 additions & 0 deletions build_resolvers/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 2.3.2

- Skip file delete for SDK summary and deps file. This will only impact behavior
for usage in `build_test` where there may be multiple resolvers used
concurrently.

## 2.3.1

- Fix a bug in the transitive digest builder, ensure we check if assets are
Expand Down
15 changes: 4 additions & 11 deletions build_resolvers/lib/src/sdk_summary.dart
Original file line number Diff line number Diff line change
Expand Up @@ -53,19 +53,12 @@ Future<String> defaultSdkSummaryGenerator() async {
package: await packagePath(package),
};

// Invalidate existing summary/version/analyzer files if present.
if (await depsFile.exists()) {
if (!await _checkDeps(depsFile, currentDeps)) {
await depsFile.delete();
if (await summaryFile.exists()) await summaryFile.delete();
}
} else if (await summaryFile.exists()) {
// Fallback for cases where we could not do a proper version check.
await summaryFile.delete();
}
final needsRebuild = !await summaryFile.exists() ||
!await depsFile.exists() ||
!await _checkDeps(depsFile, currentDeps);

// Generate the summary and version files if necessary.
if (!await summaryFile.exists()) {
if (needsRebuild) {
var watch = Stopwatch()..start();
_logger.info('Generating SDK summary...');
await summaryFile.create(recursive: true);
Expand Down
2 changes: 1 addition & 1 deletion build_resolvers/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: build_resolvers
version: 2.3.1
version: 2.3.2
description: Resolve Dart code in a Builder
repository: https://github.com/dart-lang/build/tree/master/build_resolvers

Expand Down

0 comments on commit a161297

Please sign in to comment.