TarArchiveInputStream tarIS = null;
try {
tarIS = new TarArchiveInputStream(data);
// MINOR: Assumes the first entry in the tarball is a directory.
ArchiveEntry entry;
byte[] buf = new byte[32768];
HashSet<String> names = new HashSet<String>();
boolean gotMetadata = false;
outerTAR: while(true) {
try {
entry = tarIS.getNextEntry();
} catch (IllegalArgumentException e) {
// Annoyingly, it can throw this on some corruptions...
throw new ArchiveFailureException("Error reading archive: "+e.getMessage(), e);
}
if(entry == null) break;
if(entry.isDirectory()) continue;
String name = stripLeadingSlashes(entry.getName());
if(names.contains(name)) {
Logger.error(this, "Duplicate key "+name+" in archive "+key);
continue;
}
long size = entry.getSize();
if(name.equals(".metadata"))
gotMetadata = true;
if(size > maxArchivedFileSize && !name.equals(element)) {
addErrorElement(ctx, key, name, "File too big: "+size+" greater than current archived file size limit "+maxArchivedFileSize, true);
} else {