Search in sources :

Example 1 with ArchiveEntry

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
            }
        }
    }
}
Also used : Archive(net.runelite.cache.fs.Archive) IndexEntry(net.runelite.cache.updater.beans.IndexEntry) Index(net.runelite.cache.fs.Index) ArchiveEntry(net.runelite.cache.updater.beans.ArchiveEntry) IOException(java.io.IOException)

Example 2 with ArchiveEntry

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;
}
Also used : ArchiveEntry(net.runelite.cache.updater.beans.ArchiveEntry)

Example 3 with ArchiveEntry

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);
        }
    }
}
Also used : Archive(net.runelite.cache.fs.Archive) IndexEntry(net.runelite.cache.updater.beans.IndexEntry) Index(net.runelite.cache.fs.Index) ArchiveEntry(net.runelite.cache.updater.beans.ArchiveEntry) FileData(net.runelite.cache.index.FileData)

Aggregations

ArchiveEntry (net.runelite.cache.updater.beans.ArchiveEntry)3 Archive (net.runelite.cache.fs.Archive)2 Index (net.runelite.cache.fs.Index)2 IndexEntry (net.runelite.cache.updater.beans.IndexEntry)2 IOException (java.io.IOException)1 FileData (net.runelite.cache.index.FileData)1