|
|
@ -122,16 +122,8 @@ public data class Js5MasterIndex( |
|
|
|
|
|
|
|
|
|
|
|
var nextArchive = 0 |
|
|
|
var nextArchive = 0 |
|
|
|
for (archive in store.list(Js5Archive.ARCHIVESET)) { |
|
|
|
for (archive in store.list(Js5Archive.ARCHIVESET)) { |
|
|
|
/* |
|
|
|
val entry = try { |
|
|
|
* Fill in gaps with zeroes. I think this is consistent with |
|
|
|
store.read(Js5Archive.ARCHIVESET, archive).use { buf -> |
|
|
|
* the official implementation: the TFU client warns that |
|
|
|
|
|
|
|
* entries with a zero CRC are probably invalid. |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
for (i in nextArchive until archive) { |
|
|
|
|
|
|
|
masterIndex.entries += Entry(0, 0, 0, 0, null) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
val entry = store.read(Js5Archive.ARCHIVESET, archive).use { buf -> |
|
|
|
|
|
|
|
val checksum = buf.crc32() |
|
|
|
val checksum = buf.crc32() |
|
|
|
val digest = buf.whirlpool() |
|
|
|
val digest = buf.whirlpool() |
|
|
|
|
|
|
|
|
|
|
@ -154,6 +146,31 @@ public data class Js5MasterIndex( |
|
|
|
Entry(version, checksum, groups, totalUncompressedLength, digest) |
|
|
|
Entry(version, checksum, groups, totalUncompressedLength, digest) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} catch (ex: StoreCorruptException) { |
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Unused indexes are never removed from the .idx255 file |
|
|
|
|
|
|
|
* by the client. If the .dat2 file reaches its maximum |
|
|
|
|
|
|
|
* size, it is truncated and all block numbers in the |
|
|
|
|
|
|
|
* .idx255 file will be invalid. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* Any in-use indexes will be overwritten, but unused |
|
|
|
|
|
|
|
* indexes will remain in the .idx255 file with invalid |
|
|
|
|
|
|
|
* block numbers. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* We therefore expect to see corrupt indexes sometimes. We |
|
|
|
|
|
|
|
* ignore these as if they didn't exist. |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
continue |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* |
|
|
|
|
|
|
|
* Fill in gaps with zeroes. I think this is consistent with |
|
|
|
|
|
|
|
* the official implementation: the TFU client warns that |
|
|
|
|
|
|
|
* entries with a zero CRC are probably invalid. |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
for (i in nextArchive until archive) { |
|
|
|
|
|
|
|
masterIndex.entries += Entry(0, 0, 0, 0, null) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
masterIndex.entries += entry |
|
|
|
masterIndex.entries += entry |
|
|
|
nextArchive = archive + 1 |
|
|
|
nextArchive = archive + 1 |
|
|
|