long totalSize = 0L;
for (Resource rsrc : rsrcs) {
totalSize += rsrc.getLocal().length();
}
MetaProgressObserver mpobs = new MetaProgressObserver(obs, totalSize);
boolean noUnpack = SysProps.noUnpack();
for (Resource rsrc : rsrcs) {
if (Thread.interrupted()) {
throw new InterruptedException("m.applet_stopped");
}
mpobs.startElement(rsrc.getLocal().length());
if (rsrc.isMarkedValid()) {
if (alreadyValid != null) {
alreadyValid[0]++;
}
mpobs.progress(100);
continue;
}
try {
if (_digest.validateResource(rsrc, mpobs)) {
// unpack this resource if appropriate
if (noUnpack || !rsrc.shouldUnpack()) {
// finally note that this resource is kosher
rsrc.markAsValid();
continue;
}
if (rsrc.unpack()) {
unpacked.add(rsrc);
rsrc.markAsValid();
continue;
}
log.info("Failure unpacking resource", "rsrc", rsrc);
}
} catch (Exception e) {
log.info("Failure validating resource. Requesting redownload...",
"rsrc", rsrc, "error", e);
} finally {
mpobs.progress(100);
}
failures.add(rsrc);
}
return (failures.size() == 0) ? null : failures;