Skip to content

Commit

Permalink
Properly implement dirtiness check for unresolved symlink
Browse files Browse the repository at this point in the history
This will fix warning when using `--experimental_guard_against_concurrent_changes` with unresolved symlink.

See #17162.

Closes #18588.

PiperOrigin-RevId: 538170661
Change-Id: I6c95f6281f86bf7721dc8074c8a305fe62ccca67
  • Loading branch information
coeuvre authored and copybara-github committed Jun 6, 2023
1 parent 030d94c commit c5721d8
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -735,8 +735,12 @@ public FileContentsProxy getContentsProxy() {

@Override
public boolean wasModifiedSinceDigest(Path path) {
// We could store an mtime but I have no clue where to get one from createFromMetadata
return true;
try {
var newMetadata = FileArtifactValue.createForUnresolvedSymlink(path);
return !Arrays.equals(digest, newMetadata.getDigest());
} catch (IOException e) {
return true;
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,23 @@ public void testUptodateChangeFileToDirectory() throws Exception {
assertThat(value.wasModifiedSinceDigest(path)).isTrue();
}

@Test
public void testUptodateUnresolvedSymlink() throws Exception {
Path path = fs.getPath("/dir/symlink");
path.getParentDirectory().createDirectoryAndParents();
path.createSymbolicLink(PathFragment.create("target_path"));
FileArtifactValue value = FileArtifactValue.createForUnresolvedSymlink(path);

clock.advanceMillis(1);
assertThat(value.wasModifiedSinceDigest(path)).isFalse();

path.delete();
path.createSymbolicLink(PathFragment.create("modified_target_path"));

clock.advanceMillis(1);
assertThat(value.wasModifiedSinceDigest(path)).isTrue();
}

@Test
public void addToFingerprint_equalByDigest() throws Exception {
FileArtifactValue value1 =
Expand Down

0 comments on commit c5721d8

Please sign in to comment.