Check check = new Check();
try {
is = f.newInputChannel();
// ByteBuffer fb = ByteBuffer.allocate(min(1 + data.length * 2 /*to fit couple of lines appended; never zero*/, 8192));
ByteBuffer fb = ByteBuffer.allocate(8192); // FIXME temp fix to ensure big enough buffer for KeywordFilter
FilterByteChannel filters = new FilterByteChannel(check, repo.getFiltersFromWorkingDirToRepo(p));
Preview preview = Adaptable.Factory.getAdapter(filters, Preview.class, null);
if (preview != null) {
while (is.read(fb) != -1) {
fb.flip();
preview.preview(fb);
fb.clear();
}
// reset channel to read once again
try {
is.close();
} catch (IOException ex) {
repo.getSessionContext().getLog().dump(getClass(), Info, ex, null);
}
is = f.newInputChannel();
fb.clear();
}
while (is.read(fb) != -1 && check.sameSoFar()) {
fb.flip();
filters.write(fb);
fb.compact();
}
return check.ultimatelyTheSame();
} catch (CancelledException ex) {
repo.getSessionContext().getLog().dump(getClass(), Warn, ex, "Unexpected cancellation");