Skip to content

Commit 3069ac4

Browse files
fmeumcopybara-github
authored andcommitted
Delete marker file before fetching an external repository
Fetching a repository is a long-running operation that can easily be interrupted. If it is and the marker file exists on disk, a new evaluation of the RepositoryDelegatorFunction may treat this repository as valid even though it is in an inconsistent state. Clearing the marker file before initiating the fetch and only recreating it after the fetch is complete prevents this scenario. Fixes bazelbuild#8993. Closes bazelbuild#14302. PiperOrigin-RevId: 412101756
1 parent 28409cf commit 3069ac4

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/main/java/com/google/devtools/build/lib/rules/repository/RepositoryDelegatorFunction.java

+5
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,11 @@ && managedDirectoriesExist(directories.getWorkspace(), managedDirectories)) {
339339
}
340340

341341
if (isFetch.get()) {
342+
// Fetching a repository is a long-running operation that can easily be interrupted. If it is
343+
// and the marker file exists on disk, a new call of this method may treat this repository as
344+
// valid even though it is in an inconsistent state. Clear the marker file and only recreate
345+
// it after fetching is done to prevent this scenario.
346+
DigestWriter.clearMarkerFile(directories, repositoryName);
342347
// Fetching enabled, go ahead.
343348
RepositoryDirectoryValue.Builder builder =
344349
fetchRepository(skyKey, repoRoot, env, digestWriter.getMarkerData(), handler, rule);

0 commit comments

Comments
 (0)