add a state for failed updates
This commit is contained in:
@@ -7,7 +7,7 @@ import com.muwire.core.Persona
|
|||||||
import net.i2p.util.ConcurrentHashSet
|
import net.i2p.util.ConcurrentHashSet
|
||||||
|
|
||||||
class RemoteTrustList {
|
class RemoteTrustList {
|
||||||
public enum Status { NEW, UPDATING, UPDATED }
|
public enum Status { NEW, UPDATING, UPDATED, UPDATE_FAILED }
|
||||||
|
|
||||||
private final Persona persona
|
private final Persona persona
|
||||||
private final Set<Persona> good, bad
|
private final Set<Persona> good, bad
|
||||||
|
@@ -94,13 +94,15 @@ class TrustSubscriber {
|
|||||||
public void run() {
|
public void run() {
|
||||||
trustList.status = RemoteTrustList.Status.UPDATING
|
trustList.status = RemoteTrustList.Status.UPDATING
|
||||||
eventBus.publish(new TrustSubscriptionUpdatedEvent(trustList : trustList))
|
eventBus.publish(new TrustSubscriptionUpdatedEvent(trustList : trustList))
|
||||||
check(trustList, System.currentTimeMillis())
|
if (check(trustList, System.currentTimeMillis()))
|
||||||
trustList.status = RemoteTrustList.Status.UPDATED
|
trustList.status = RemoteTrustList.Status.UPDATED
|
||||||
|
else
|
||||||
|
trustList.status = RemoteTrustList.Status.UPDATE_FAILED
|
||||||
eventBus.publish(new TrustSubscriptionUpdatedEvent(trustList : trustList))
|
eventBus.publish(new TrustSubscriptionUpdatedEvent(trustList : trustList))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void check(RemoteTrustList trustList, long now) {
|
private boolean check(RemoteTrustList trustList, long now) {
|
||||||
log.info("fetching trust list from ${trustList.persona.getHumanReadableName()}")
|
log.info("fetching trust list from ${trustList.persona.getHumanReadableName()}")
|
||||||
Endpoint endpoint = null
|
Endpoint endpoint = null
|
||||||
try {
|
try {
|
||||||
@@ -118,7 +120,7 @@ class TrustSubscriber {
|
|||||||
|
|
||||||
if (code != 200) {
|
if (code != 200) {
|
||||||
log.info("couldn't fetch trust list, code $code")
|
log.info("couldn't fetch trust list, code $code")
|
||||||
return
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
// swallow any headers
|
// swallow any headers
|
||||||
@@ -147,8 +149,10 @@ class TrustSubscriber {
|
|||||||
trustList.bad.clear()
|
trustList.bad.clear()
|
||||||
trustList.bad.addAll(bad)
|
trustList.bad.addAll(bad)
|
||||||
|
|
||||||
|
return true
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.log(Level.WARNING,"exception fetching trust list from ${trustList.persona.getHumanReadableName()}",e)
|
log.log(Level.WARNING,"exception fetching trust list from ${trustList.persona.getHumanReadableName()}",e)
|
||||||
|
return false
|
||||||
} finally {
|
} finally {
|
||||||
endpoint?.close()
|
endpoint?.close()
|
||||||
}
|
}
|
||||||
|
@@ -488,6 +488,11 @@ class MainFrameView {
|
|||||||
model.updateButtonEnabled = true
|
model.updateButtonEnabled = true
|
||||||
model.unsubscribeButtonEnabled = true
|
model.unsubscribeButtonEnabled = true
|
||||||
break
|
break
|
||||||
|
case RemoteTrustList.Status.UPDATE_FAILED:
|
||||||
|
model.reviewButtonEnabled = false
|
||||||
|
model.updateButtonEnabled = true
|
||||||
|
model.unsubscribeButtonEnabled = true
|
||||||
|
break
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user