@return true if information was consistent, false otherwise
*/
public boolean doConsistencyCheck() {
boolean isConsistent = true;
boolean needsHashCheck = false;
ODMGXAWrapper txw = new ODMGXAWrapper();
txw.lock( this, Transaction.WRITE );
File f = this.getImageFile();
if ( f.exists() ) {
long size = f.length();
if ( size != this.fileSize ) {
isConsistent = false;
if ( this.fileSize == 0 ) {
needsHashCheck = true;
}
}
long mtime = f.lastModified();
if ( mtime != this.mtime ) {
needsHashCheck = true;
}
if ( needsHashCheck ) {
byte[] dbHash = (byte[]) hash.clone();
calcHash();
byte[] realHash = (byte[])hash.clone();
isConsistent = Arrays.equals( dbHash, realHash );
if ( isConsistent ) {
txw.lock( this, Transaction.WRITE );
this.mtime = mtime;
this.fileSize = size;
}
}
}
/* Update the database with check result if it was positive */
if ( isConsistent ) {
txw.lock( this, Transaction.WRITE );
this.checkTime = new java.util.Date();
}
txw.commit();
return isConsistent;
}