activityDataObject.dispatch(activityReceiver);
}
protected boolean isInconsistent(ChecksumActivity checksum) {
SPath path = checksum.getPath();
IFile file = path.getFile();
if (!checksum.existsFile()) {
/*
* If the checksum tells us that the file does not exist at the
* host, check whether we still have it. If it exists, we do have an
* inconsistency
*/
return file.exists();
}
/*
* If the checksum tells us, that the file exists, but we do not have
* it, it is an inconsistency as well
*/
if (!file.exists()) {
return true;
}
FileEditorInput input = new FileEditorInput(file);
IDocumentProvider provider = EditorManager.getDocumentProvider(input);
try {
provider.connect(input);
} catch (CoreException e) {
log.warn("Could not check checksum of file " + path.toString());
return false;
}
try {
IDocument doc = provider.getDocument(input);
// if doc is still null give up
if (doc == null) {
log.warn("Could not check checksum of file " + path.toString());
return false;
}
if ((doc.getLength() != checksum.getLength())
|| (doc.get().hashCode() != checksum.getHash())) {
log.debug(String.format(
"Inconsistency detected: %s L(%d %s %d) H(%x %s %x)", path
.toString(), doc.getLength(),
doc.getLength() == checksum.getLength() ? "==" : "!=",
checksum.getLength(), doc.get().hashCode(), doc.get()
.hashCode() == checksum.getHash() ? "==" : "!=",
checksum.getHash()));