Skip to content

Commit

Permalink
Suppresses error logging for 76 char header diffs
Browse files Browse the repository at this point in the history
This is a recurring error due to header problems. Temporary patches #128.
  • Loading branch information
ianmilligan1 committed Dec 4, 2017
1 parent be7eeed commit 5ce3608
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/main/java/io/archivesunleashed/data/ArcRecordUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,13 @@
* Utilities for working with {@code ARCRecord}s (from archive.org APIs).
*/
public final class ArcRecordUtils {

/**
* Due to ARC header differences, until we merge code to reflect new
* webarchive-discovery version, a consistant difference of 76 bytes
* in ARC files is expected.
*/
public static final long HEADER_DIFF = 76;
/**
* Utility classes should not have a public or default constructor.
*/
private ArcRecordUtils() {
Expand Down Expand Up @@ -81,7 +86,7 @@ public static byte[] toBytes(final ARCRecord record) throws IOException {
long recordLength = meta.getLength();
long len = IOUtils.copyLarge(new BoundedInputStream(record, recordLength),
dout);
if (len != recordLength) {
if (len != recordLength + HEADER_DIFF) {
LOG.error("Read " + len + " bytes but expected " + recordLength
+ " bytes. Continuing...");
}
Expand Down Expand Up @@ -142,9 +147,10 @@ private static byte[] copyToByteArray(final InputStream is,

BoundedInputStream bis = new BoundedInputStream(is, recordLength);
byte[] rawContents = IOUtils.toByteArray(bis);
if (enforceLength && rawContents.length != recordLength) {
if (!(rawContents.length == recordLength - HEADER_DIFF
|| rawContents.length == recordLength)) {
LOG.error("Read " + rawContents.length + " bytes but expected "
+ recordLength + " bytes. Continuing...");
+ recordLength + " bytes. Continuing...");
}
return rawContents;
}
Expand Down

0 comments on commit 5ce3608

Please sign in to comment.