wiki-scraper/cache: Fix NPE

This commit is contained in:
Owain van Brakel
2019-08-15 23:47:59 +02:00
parent 8239be4b75
commit 1c45af2404
2 changed files with 26 additions and 5 deletions

View File

@@ -112,8 +112,13 @@ public class DiskStorage implements Storage
public byte[] readIndex(int indexId) throws IOException
{
IndexEntry entry = index255.read(indexId);
byte[] indexData = data.read(index255.getIndexFileId(), entry.getId(), entry.getSector(), entry.getLength());
return indexData;
if (entry != null)
{
byte[] indexData = data.read(index255.getIndexFileId(), entry.getId(), entry.getSector(), entry.getLength());
return indexData;
}
return null;
}
private void loadIndex(Index index) throws IOException
@@ -121,6 +126,12 @@ public class DiskStorage implements Storage
logger.trace("Loading index {}", index.getId());
byte[] indexData = readIndex(index.getId());
if (indexData == null)
{
return;
}
Container res = Container.decompress(indexData, null);
byte[] data = res.data;