Align PackStatistics and DfsPackDescription list length

Without this the caller cannot tell which PackStatistics is for which
pack file.

Change-Id: Ifa530f8bc82459611ae694c0a0d111daec3e08f3
Signed-off-by: Masaya Suzuki <masayasuzuki@google.com>
This commit is contained in:
Masaya Suzuki 2017-10-20 12:18:16 -07:00
parent 7cd5d77ae3
commit 45837ff189
2 changed files with 14 additions and 4 deletions

View File

@ -486,7 +486,12 @@ public List<DfsPackDescription> getNewPacks() {
return newPackDesc; return newPackDesc;
} }
/** @return statistics corresponding to the {@link #getNewPacks()}. */ /**
* @return statistics corresponding to the {@link #getNewPacks()}.
*
* <p>The elements can be null if the stat is not available for the pack
* file.
*/
public List<PackStatistics> getNewPackStatistics() { public List<PackStatistics> getNewPackStatistics() {
return newPackStats; return newPackStats;
} }
@ -637,7 +642,6 @@ private DfsPackDescription writePack(PackSource source, PackWriter pw,
ProgressMonitor pm, long estimatedPackSize) throws IOException { ProgressMonitor pm, long estimatedPackSize) throws IOException {
DfsPackDescription pack = repo.getObjectDatabase().newPack(source, DfsPackDescription pack = repo.getObjectDatabase().newPack(source,
estimatedPackSize); estimatedPackSize);
newPackDesc.add(pack);
if (source == GC && reftableConfig != null) { if (source == GC && reftableConfig != null) {
writeReftable(pack); writeReftable(pack);
@ -671,6 +675,7 @@ private DfsPackDescription writePack(PackSource source, PackWriter pw,
PackStatistics stats = pw.getStatistics(); PackStatistics stats = pw.getStatistics();
pack.setPackStats(stats); pack.setPackStats(stats);
pack.setLastModified(startTimeMillis); pack.setLastModified(startTimeMillis);
newPackDesc.add(pack);
newPackStats.add(stats); newPackStats.add(stats);
newPackObj.add(pw.getObjectSet()); newPackObj.add(pw.getObjectSet());
return pack; return pack;
@ -680,6 +685,7 @@ private void writeReftable() throws IOException {
if (reftableConfig != null) { if (reftableConfig != null) {
DfsPackDescription pack = objdb.newPack(GC); DfsPackDescription pack = objdb.newPack(GC);
newPackDesc.add(pack); newPackDesc.add(pack);
newPackStats.add(null);
writeReftable(pack); writeReftable(pack);
} }
} }

View File

@ -350,9 +350,13 @@ public List<DfsPackDescription> getNewPacks() {
: Collections.emptyList(); : Collections.emptyList();
} }
/** @return statistics corresponding to the {@link #getNewPacks()}. */ /**
* @return statistics corresponding to the {@link #getNewPacks()}.
*
* <p>The element may be null if the stat is not available.
*/
public List<PackStatistics> getNewPackStatistics() { public List<PackStatistics> getNewPackStatistics() {
return newStats != null return outDesc != null
? Collections.singletonList(newStats) ? Collections.singletonList(newStats)
: Collections.emptyList(); : Collections.emptyList();
} }