From a1612976aefe6b2ac38094febe477559556c10f0 Mon Sep 17 00:00:00 2001 From: Nate Bosch Date: Wed, 6 Sep 2023 09:31:54 -0700 Subject: [PATCH] Skip delete for SDK summary and deps file (#3573) 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. --- build_resolvers/CHANGELOG.md | 6 ++++++ build_resolvers/lib/src/sdk_summary.dart | 15 ++++----------- build_resolvers/pubspec.yaml | 2 +- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/build_resolvers/CHANGELOG.md b/build_resolvers/CHANGELOG.md index 57ecfe63e..8e02102b1 100644 --- a/build_resolvers/CHANGELOG.md +++ b/build_resolvers/CHANGELOG.md @@ -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 diff --git a/build_resolvers/lib/src/sdk_summary.dart b/build_resolvers/lib/src/sdk_summary.dart index 223761471..8c4b49157 100644 --- a/build_resolvers/lib/src/sdk_summary.dart +++ b/build_resolvers/lib/src/sdk_summary.dart @@ -53,19 +53,12 @@ Future 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); diff --git a/build_resolvers/pubspec.yaml b/build_resolvers/pubspec.yaml index 872c99f42..e3a280112 100644 --- a/build_resolvers/pubspec.yaml +++ b/build_resolvers/pubspec.yaml @@ -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