forked from I2P_Developers/i2p.i2p
i2psnark: Fix bad completion status after recheck (ticket #2046)
Only occurred if torrent had previously run, was previously incomplete, and was now complete. Also fixed changed-after-recheck logic to be precise.
This commit is contained in:
@ -170,7 +170,24 @@ public class BitField
|
|||||||
return count >= size;
|
return count >= size;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
/** @since 0.9.33 */
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return (count << 16) ^ size;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @since 0.9.33 */
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (o == null || !(o instanceof BitField))
|
||||||
|
return false;
|
||||||
|
BitField bf = (BitField) o;
|
||||||
|
return count == bf.count() &&
|
||||||
|
size == bf.size() &&
|
||||||
|
Arrays.equals(bitfield, bf.getFieldBytes());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String toString()
|
public String toString()
|
||||||
{
|
{
|
||||||
// Not very efficient
|
// Not very efficient
|
||||||
|
@ -892,9 +892,7 @@ public class Storage implements Closeable
|
|||||||
* @since 0.9.23
|
* @since 0.9.23
|
||||||
*/
|
*/
|
||||||
public boolean recheck() throws IOException {
|
public boolean recheck() throws IOException {
|
||||||
int previousNeeded = needed;
|
boolean changed = checkCreateFiles(true);
|
||||||
checkCreateFiles(true);
|
|
||||||
boolean changed = previousNeeded != needed;
|
|
||||||
if (listener != null && changed)
|
if (listener != null && changed)
|
||||||
listener.setWantedPieces(this);
|
listener.setWantedPieces(this);
|
||||||
return changed;
|
return changed;
|
||||||
@ -910,19 +908,23 @@ public class Storage implements Closeable
|
|||||||
* @param recheck if true, this is a check after we downloaded the
|
* @param recheck if true, this is a check after we downloaded the
|
||||||
* last piece, and we don't modify the global bitfield unless
|
* last piece, and we don't modify the global bitfield unless
|
||||||
* the check fails.
|
* the check fails.
|
||||||
|
* @return true if changed (only valid if recheck == true)
|
||||||
*/
|
*/
|
||||||
private void checkCreateFiles(boolean recheck) throws IOException {
|
private boolean checkCreateFiles(boolean recheck) throws IOException {
|
||||||
synchronized(this) {
|
synchronized(this) {
|
||||||
_isChecking = true;
|
_isChecking = true;
|
||||||
try {
|
try {
|
||||||
locked_checkCreateFiles(recheck);
|
return locked_checkCreateFiles(recheck);
|
||||||
} finally {
|
} finally {
|
||||||
_isChecking = false;
|
_isChecking = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void locked_checkCreateFiles(boolean recheck) throws IOException
|
/**
|
||||||
|
* @return true if changed (only valid if recheck == true)
|
||||||
|
*/
|
||||||
|
private boolean locked_checkCreateFiles(boolean recheck) throws IOException
|
||||||
{
|
{
|
||||||
_checkProgress.set(0);
|
_checkProgress.set(0);
|
||||||
// Whether we are resuming or not,
|
// Whether we are resuming or not,
|
||||||
@ -1033,9 +1035,11 @@ public class Storage implements Closeable
|
|||||||
|
|
||||||
// do this here so we don't confuse the user during checking
|
// do this here so we don't confuse the user during checking
|
||||||
needed = need;
|
needed = need;
|
||||||
if (recheck && need > 0) {
|
boolean rv = false;
|
||||||
// whoops, recheck failed
|
if (recheck) {
|
||||||
|
// FIXME bogus synch
|
||||||
synchronized(bitfield) {
|
synchronized(bitfield) {
|
||||||
|
rv = !bfield.equals(bitfield);
|
||||||
bitfield = bfield;
|
bitfield = bfield;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1045,6 +1049,7 @@ public class Storage implements Closeable
|
|||||||
if (needed <= 0)
|
if (needed <= 0)
|
||||||
listener.storageCompleted(this);
|
listener.storageCompleted(this);
|
||||||
}
|
}
|
||||||
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,3 +1,7 @@
|
|||||||
|
2017-11-16 zzz
|
||||||
|
* i2psnark: Fix bad completion status after recheck (ticket #2046)
|
||||||
|
* Jetty 9.2.22
|
||||||
|
|
||||||
2017-11-07 zzz
|
2017-11-07 zzz
|
||||||
* Utils: Constant-time password check
|
* Utils: Constant-time password check
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ public class RouterVersion {
|
|||||||
/** deprecated */
|
/** deprecated */
|
||||||
public final static String ID = "Monotone";
|
public final static String ID = "Monotone";
|
||||||
public final static String VERSION = CoreVersion.VERSION;
|
public final static String VERSION = CoreVersion.VERSION;
|
||||||
public final static long BUILD = 1;
|
public final static long BUILD = 2;
|
||||||
|
|
||||||
/** for example "-test" */
|
/** for example "-test" */
|
||||||
public final static String EXTRA = "";
|
public final static String EXTRA = "";
|
||||||
|
Reference in New Issue
Block a user