Commit ab67ab1a by olly Committed by Oliver Woodman

Implement database CachedContentIndex.Storage

PiperOrigin-RevId: 231600104
parent c9b848e5
...@@ -408,8 +408,8 @@ public final class SimpleCache implements Cache { ...@@ -408,8 +408,8 @@ public final class SimpleCache implements Cache {
if (isRootDirectory && fileName.indexOf('.') == -1) { if (isRootDirectory && fileName.indexOf('.') == -1) {
loadDirectory(file, /* isRootDirectory= */ false); loadDirectory(file, /* isRootDirectory= */ false);
} else { } else {
if (isRootDirectory && CachedContentIndex.FILE_NAME.equals(fileName)) { if (isRootDirectory && CachedContentIndex.isIndexFile(fileName)) {
// Skip the (expected) index file in the root directory. // Skip the (expected) index files in the root directory.
continue; continue;
} }
long fileLength = file.length(); long fileLength = file.length();
......
...@@ -151,7 +151,8 @@ public class CachedContentIndexTest { ...@@ -151,7 +151,8 @@ public class CachedContentIndexTest {
@Test @Test
public void testLoadV1() throws Exception { public void testLoadV1() throws Exception {
FileOutputStream fos = new FileOutputStream(new File(cacheDir, CachedContentIndex.FILE_NAME)); FileOutputStream fos =
new FileOutputStream(new File(cacheDir, CachedContentIndex.FILE_NAME_ATOMIC));
fos.write(testIndexV1File); fos.write(testIndexV1File);
fos.close(); fos.close();
...@@ -169,7 +170,8 @@ public class CachedContentIndexTest { ...@@ -169,7 +170,8 @@ public class CachedContentIndexTest {
@Test @Test
public void testLoadV2() throws Exception { public void testLoadV2() throws Exception {
FileOutputStream fos = new FileOutputStream(new File(cacheDir, CachedContentIndex.FILE_NAME)); FileOutputStream fos =
new FileOutputStream(new File(cacheDir, CachedContentIndex.FILE_NAME_ATOMIC));
fos.write(testIndexV2File); fos.write(testIndexV2File);
fos.close(); fos.close();
...@@ -220,7 +222,7 @@ public class CachedContentIndexTest { ...@@ -220,7 +222,7 @@ public class CachedContentIndexTest {
new CachedContentIndex(cacheDir, key), new CachedContentIndex(cacheDir, key)); new CachedContentIndex(cacheDir, key), new CachedContentIndex(cacheDir, key));
// Rename the index file from the test above // Rename the index file from the test above
File file1 = new File(cacheDir, CachedContentIndex.FILE_NAME); File file1 = new File(cacheDir, CachedContentIndex.FILE_NAME_ATOMIC);
File file2 = new File(cacheDir, "file2compare"); File file2 = new File(cacheDir, "file2compare");
assertThat(file1.renameTo(file2)).isTrue(); assertThat(file1.renameTo(file2)).isTrue();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment