So there are archives not in the index, not sure what to do with it

This commit is contained in:
Adam
2015-10-17 16:28:52 -04:00
parent 5e28fe9768
commit 9b5a7981aa
3 changed files with 21 additions and 2 deletions

View File

@@ -9,9 +9,13 @@ import java.util.List;
import java.util.Objects;
import net.runelite.cache.fs.io.InputStream;
import net.runelite.cache.fs.io.OutputStream;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class Index implements Closeable
{
private static final Logger logger = LoggerFactory.getLogger(Index.class);
private final Store store;
private final IndexFile index;
private final int id;
@@ -227,6 +231,12 @@ public class Index implements Closeable
for (Archive a : archives)
{
IndexEntry entry = this.index.read(a.getArchiveId());
if (entry == null)
{
logger.warn("can't read archive " + a.getArchiveId() + " from index " + this.id);
continue;
}
assert this.index.getIndexFileId() == this.id;
assert entry.getId() == a.getArchiveId();
DataFileReadResult res = store.getData().read(this.id, entry.getId(), entry.getSector(), entry.getLength()); // needs decompress etc...

View File

@@ -91,11 +91,20 @@ public class IndexFile implements Closeable
idx.seek(id * INDEX_ENTRY_LEN);
int i = idx.read(buffer);
if (i != INDEX_ENTRY_LEN)
logger.warn("short read");
{
logger.warn("short read for id {}: {}", id, i);
return null;
}
int length = ((buffer[0] & 0xFF) << 16) | ((buffer[1] & 0xFF) << 8) | (buffer[2] & 0xFF);
int sector = ((buffer[3] & 0xFF) << 16) | ((buffer[4] & 0xFF) << 8) | (buffer[5] & 0xFF);
if (length <= 0 || sector <= 0)
{
logger.warn("invalid length or sector {}/{}", length, sector);
return null;
}
return new IndexEntry(this, id, sector, length);
}

View File

@@ -102,7 +102,7 @@ public class Store implements Closeable
{
int id = i.getIndex().getIndexFileId();
if (id == 5)
break;
continue;
i.load();
}
}