i2psnark: Synch operations on BitField byte array

This commit is contained in:
zzz
2017-12-07 19:44:56 +00:00
parent 7f673bb254
commit 1f569b7359
3 changed files with 31 additions and 12 deletions

View File

@@ -1671,7 +1671,8 @@ public class SnarkManager implements CompleteListener, ClientApp {
}
if (autoStart) {
startTorrent(ih);
addMessage(_t("Fetching {0}", name));
if (false)
addMessage(_t("Fetching {0}", name));
DHT dht = _util.getDHT();
boolean shouldWarn = _util.connected() &&
_util.getOpenTrackers().isEmpty() &&
@@ -2053,14 +2054,16 @@ public class SnarkManager implements CompleteListener, ClientApp {
if (config.getProperty(PROP_META_ADDED) == null)
config.setProperty(PROP_META_ADDED, now);
String bfs;
if (bitfield.complete()) {
bfs = ".";
if (config.getProperty(PROP_META_COMPLETED) == null)
config.setProperty(PROP_META_COMPLETED, now);
} else {
byte[] bf = bitfield.getFieldBytes();
bfs = Base64.encode(bf);
config.remove(PROP_META_COMPLETED);
synchronized(bitfield) {
if (bitfield.complete()) {
bfs = ".";
if (config.getProperty(PROP_META_COMPLETED) == null)
config.setProperty(PROP_META_COMPLETED, now);
} else {
byte[] bf = bitfield.getFieldBytes();
bfs = Base64.encode(bf);
config.remove(PROP_META_COMPLETED);
}
}
config.setProperty(PROP_META_BITFIELD, bfs);
config.setProperty(PROP_META_PRESERVE_NAMES, Boolean.toString(preserveNames));