Skip to content

Commit

Permalink
Delete marker file before fetching an external repository
Browse files Browse the repository at this point in the history
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
  • Loading branch information
fmeum authored and copybara-github committed Nov 24, 2021
1 parent 28409cf commit 3069ac4
Showing 1 changed file with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,11 @@ && managedDirectoriesExist(directories.getWorkspace(), managedDirectories)) {
}

if (isFetch.get()) {
// 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 call of this method may treat this repository as
// valid even though it is in an inconsistent state. Clear the marker file and only recreate
// it after fetching is done to prevent this scenario.
DigestWriter.clearMarkerFile(directories, repositoryName);
// Fetching enabled, go ahead.
RepositoryDirectoryValue.Builder builder =
fetchRepository(skyKey, repoRoot, env, digestWriter.getMarkerData(), handler, rule);
Expand Down

0 comments on commit 3069ac4

Please sign in to comment.