review cosmetics
@@ -465,9 +465,15 @@ private Archive readHeaders(final byte[] password) throws IOException {
return initializeArchive(startHeader, password, true);
} else {
// No valid header found - probably first file of multipart archive was removed too early. Scan for end header.
+ return tryToLocateEndHeader(password);
+ }
+ }
+
+ private Archive tryToLocateEndHeader(final byte[] password) throws IOException {
ByteBuffer nidBuf = ByteBuffer.allocate(1);
final long searchLimit = 1024 * 1024 * 1;
- final long previousDataSize = channel.position() + 20; // Main header, plus bytes that readStartHeader would read
+ // Main header, plus bytes that readStartHeader would read
+ final long previousDataSize = channel.position() + 20;
final long minPos;
// Determine minimal position - can't start before current position
if (channel.position() + searchLimit > channel.size()) {
@@ -484,7 +490,7 @@ private Archive readHeaders(final byte[] password) throws IOException {
channel.read(nidBuf);
int nid = nidBuf.array()[0];
// First indicator: Byte equals one of these header identifiers
- if ((nid == NID.kEncodedHeader) || (nid == NID.kHeader)) {
+ if (nid == NID.kEncodedHeader || nid == NID.kHeader) {
try {
// Try to initialize Archive structure from here
final StartHeader startHeader = new StartHeader();
@@ -502,7 +508,6 @@ private Archive readHeaders(final byte[] password) throws IOException {
}
throw new IOException("Start header corrupt and unable to guess end header");
}
- }
private Archive initializeArchive(StartHeader startHeader, final byte[] password, boolean verifyCrc) throws IOException {
assertFitsIntoInt("nextHeaderSize", startHeader.nextHeaderSize);
