Re: [core-dev] VerifyingFile returns false positivies when checkingfor file corruptions
Gregorio Roper <[email protected]> Tue, 26 Jul 2005 13:53:18 +0200
| Newsgroups | gmane.network.gnutella.limewire.core.devel |
|---|---|
| Message-ID | <[email protected]> |
I've found this out today:
When reverifying a range immediately after it turned out to be corrupt, the
same range, when re-read from the RandomAccessFile and re-verified can be
identified as not being corrupt.
That at least narrows it down to either the RandomAccessFile class which might
be broken on Linux or the TigerTree class being broken. (I would put my money
on a problem in the RandomAccessFile.)
--
mfg
gregorio roper
The modified VerifyingFile#verifyChunk method I used....
/**
* @return whether this chunk is corrupt according to the given hash tree
*/
private boolean verifyChunk(Interval i, HashTree tree) {
if (LOG.isDebugEnabled())
LOG.debug("verifying interval "+i);
byte []b = getChunkBuf(i.high - i.low+1);
// read the interval from the file
try {
synchronized(fos) {
fos.seek(i.low);
fos.readFully(b);
}
} catch (IOException bad) {
// we failed reading back from the file - assume block is corrupt
// and it will have to be re-downloaded
return false;
}
boolean corrupt = tree.isCorrupt(i,b);
if (LOG.isDebugEnabled() && corrupt) {
LOG.debug("block corrupt!");
try {
synchronized(fos) {
fos.seek(i.low);
fos.readFully(b);
}
} catch (IOException bad) {
return false;
}
LOG.debug("recheck: " + tree.isCorrupt(i,b));
}
return !corrupt;
}
_______________________________________________
core-dev mailing list
[email protected]
http://www.limewire.org/mailman/listinfo/core-dev