DfsObjDatabase: clear PackList dirty bit if no new packs

If a reference was updated more recently than a pack was written
(typical) the PackList was perpetually dirty until the next GC
was completed for the repository.

Detect this condition by observing no changes to the PackList
membership and resetting the dirty bit.

Change-Id: Ie2133aca1f8083307c73b6a26358175864f100ef
This commit is contained in:
Shawn Pearce 2016-08-19 11:51:40 -07:00
parent 13f0db25f2
commit f15e9c088a
1 changed files with 14 additions and 1 deletions

View File

@ -67,6 +67,11 @@ boolean dirty() {
return true;
}
@Override
void clearDirty() {
// Always dirty.
}
@Override
public void markDirty() {
// Always dirty.
@ -443,8 +448,10 @@ private PackList scanPacksImpl(PackList old) throws IOException {
p.close();
if (list.isEmpty())
return new PackListImpl(NO_PACKS.packs);
if (!foundNew)
if (!foundNew) {
old.clearDirty();
return old;
}
return new PackListImpl(list.toArray(new DfsPackFile[list.size()]));
}
@ -514,6 +521,7 @@ public long getLastModified() {
}
abstract boolean dirty();
abstract void clearDirty();
/**
* Mark pack list as dirty.
@ -537,6 +545,11 @@ boolean dirty() {
return dirty;
}
@Override
void clearDirty() {
dirty = false;
}
@Override
public void markDirty() {
dirty = true;