use of net.runelite.cache.updater.beans.ArchiveEntry in project runelite by runelite.
the class CacheStorage method load.
@Override
public void load(Store store) throws IOException {
List<IndexEntry> indexes = cacheDao.findIndexesForCache(con, cacheEntry);
for (IndexEntry indexEntry : indexes) {
Index index = store.addIndex(indexEntry.getIndexId());
index.setCrc(indexEntry.getCrc());
index.setRevision(indexEntry.getRevision());
try (ResultSetIterable<ArchiveEntry> archives = cacheDao.findArchivesForIndex(con, indexEntry)) {
for (ArchiveEntry archiveEntry : archives) {
if (index.getArchive(archiveEntry.getArchiveId()) != null) {
throw new IOException("Duplicate archive " + archiveEntry + " on " + indexEntry);
}
Archive archive = index.addArchive(archiveEntry.getArchiveId());
archive.setNameHash(archiveEntry.getNameHash());
archive.setCrc(archiveEntry.getCrc());
archive.setRevision(archiveEntry.getRevision());
archive.setHash(archiveEntry.getHash());
// File data is not necessary for cache updating
}
}
}
}
use of net.runelite.cache.updater.beans.ArchiveEntry in project runelite by runelite.
the class CacheDAO method createArchive.
public ArchiveEntry createArchive(Connection con, IndexEntry index, int archiveId, int nameHash, int crc, int revision, byte[] hash) {
if (insertArchive == null) {
insertArchive = con.createQuery("insert into archive (archiveId, nameHash, crc, revision, hash) values " + "(:archiveId, :nameHash, :crc, :revision, :hash)");
}
int id = insertArchive.addParameter("archiveId", archiveId).addParameter("nameHash", nameHash).addParameter("crc", crc).addParameter("revision", revision).addParameter("hash", hash).executeUpdate().getKey(int.class);
ArchiveEntry entry = new ArchiveEntry();
entry.setId(id);
entry.setArchiveId(archiveId);
entry.setNameHash(nameHash);
entry.setCrc(crc);
entry.setRevision(revision);
entry.setHash(hash);
return entry;
}
use of net.runelite.cache.updater.beans.ArchiveEntry in project runelite by runelite.
the class CacheStorage method save.
@Override
public void save(Store store) throws IOException {
for (Index index : store.getIndexes()) {
IndexEntry entry = cacheDao.createIndex(con, cacheEntry, index.getId(), index.getCrc(), index.getRevision());
for (Archive archive : index.getArchives()) {
ArchiveEntry archiveEntry = cacheDao.findArchive(con, entry, archive.getArchiveId(), archive.getNameHash(), archive.getCrc(), archive.getRevision());
if (archiveEntry == null) {
byte[] hash = archive.getHash();
archiveEntry = cacheDao.createArchive(con, entry, archive.getArchiveId(), archive.getNameHash(), archive.getCrc(), archive.getRevision(), hash);
for (FileData file : archive.getFileData()) {
cacheDao.associateFileToArchive(con, archiveEntry, file.getId(), file.getNameHash());
}
}
cacheDao.associateArchiveToIndex(con, archiveEntry, entry);
}
}
}
Aggregations