in src/main/java/org/apache/sling/fileoptim/impl/FileOptimizerServiceImpl.java [199:215]
public boolean isOptimized(Resource fileResource) {
if (!fileResource.getName().equals(JcrConstants.JCR_CONTENT)
&& fileResource.getChild(JcrConstants.JCR_CONTENT) != null) {
fileResource = fileResource.getChild(JcrConstants.JCR_CONTENT);
}
OptimizedFile of = fileResource.adaptTo(OptimizedFile.class);
try {
String calculatedHash = calculateHash(IOUtils.toByteArray(of.getContent()));
log.debug("Comparing stored {} and calculated {} hashes", of.getHash(), calculatedHash);
return Objects.equals(of.getHash(), calculatedHash);
} catch (IOException e) {
log.error("Exception checking if file optimized, assuming false", e);
return false;
}
}