@@ -52,6 +52,8 @@ public class CompactPersistentActionCacheTest {
5252 private Path dataRoot ;
5353 private Path mapFile ;
5454 private Path journalFile ;
55+ private Path indexFile ;
56+ private Path indexJournalFile ;
5557 private final ManualClock clock = new ManualClock ();
5658 private CompactPersistentActionCache cache ;
5759 private ArtifactRoot artifactRoot ;
@@ -62,6 +64,8 @@ public final void createFiles() throws Exception {
6264 cache = CompactPersistentActionCache .create (dataRoot , clock , NullEventHandler .INSTANCE );
6365 mapFile = CompactPersistentActionCache .cacheFile (dataRoot );
6466 journalFile = CompactPersistentActionCache .journalFile (dataRoot );
67+ indexFile = CompactPersistentActionCache .indexFile (dataRoot );
68+ indexJournalFile = CompactPersistentActionCache .indexJournalFile (dataRoot );
6569 artifactRoot =
6670 ArtifactRoot .asDerivedRoot (
6771 scratch .getFileSystem ().getPath ("/output" ), ArtifactRoot .RootType .Output , "bin" );
@@ -77,6 +81,21 @@ public void testDeleteUnrecognizedFiles() throws Exception {
7781 assertThat (unrecognizedFile .exists ()).isFalse ();
7882 }
7983
84+ @ Test
85+ public void testRenameCorruptedFiles () throws Exception {
86+ FileSystemUtils .writeContentAsLatin1 (mapFile , "corrupted data" );
87+ FileSystemUtils .writeContentAsLatin1 (journalFile , "corrupted data" );
88+ FileSystemUtils .writeContentAsLatin1 (indexFile , "corrupted data" );
89+ FileSystemUtils .writeContentAsLatin1 (indexJournalFile , "corrupted data" );
90+
91+ cache = CompactPersistentActionCache .create (dataRoot , clock , NullEventHandler .INSTANCE );
92+
93+ assertThat (CompactPersistentActionCache .corruptedPath (mapFile ).exists ()).isTrue ();
94+ assertThat (CompactPersistentActionCache .corruptedPath (journalFile ).exists ()).isTrue ();
95+ assertThat (CompactPersistentActionCache .corruptedPath (indexFile ).exists ()).isTrue ();
96+ assertThat (CompactPersistentActionCache .corruptedPath (indexJournalFile ).exists ()).isTrue ();
97+ }
98+
8099 @ Test
81100 public void testGetInvalidKey () {
82101 assertThat (cache .get ("key" )).isNull ();
0 commit comments