Skip to content

Commit dd8fe77

Browse files
authored
Delete marker file before fetching an external repository (#14324)
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 748138f commit dd8fe77

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,11 @@ && managedDirectoriesExist(directories.getWorkspace(), managedDirectories)) {
271271
}
272272

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

0 commit comments

Comments
 (0)