Skip to content

Commit dc76f74

Browse files
authored
Delete marker file before fetching an external repository (#14323)
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 #8993. Closes #14302. PiperOrigin-RevId: 412101756
1 parent f948989 commit dc76f74

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)