Exemplo n.º 1
0
 private void assumeUnchanged(String path) throws IOException {
   final DirCache dirc = db.lockDirCache();
   final DirCacheEntry ent = dirc.getEntry(path);
   if (ent != null) ent.setAssumeValid(true);
   dirc.write();
   if (!dirc.commit()) throw new IOException("could not commit");
 }
Exemplo n.º 2
0
  @Test
  public void testWriteEmptyUnlock_RealIndex() throws Exception {
    final File idx = new File(db.getDirectory(), "index");
    final File lck = new File(db.getDirectory(), "index.lock");
    assertFalse(idx.exists());
    assertFalse(lck.exists());

    final DirCache dc = db.lockDirCache();
    assertEquals(0, lck.length());
    dc.write();
    assertEquals(12 + 20, lck.length());

    dc.unlock();
    assertFalse(idx.exists());
    assertFalse(lck.exists());
  }
Exemplo n.º 3
0
 @Test
 public void testWriteEmptyReadEmpty_RealIndex() throws Exception {
   final File idx = new File(db.getDirectory(), "index");
   final File lck = new File(db.getDirectory(), "index.lock");
   assertFalse(idx.exists());
   assertFalse(lck.exists());
   {
     final DirCache dc = db.lockDirCache();
     dc.write();
     assertTrue(dc.commit());
     assertTrue(idx.exists());
   }
   {
     final DirCache dc = db.readDirCache();
     assertEquals(0, dc.getEntryCount());
   }
 }