more efficient persisting
This commit is contained in:
@@ -103,10 +103,12 @@ class PersisterService extends Service {
|
|||||||
private void persistFiles() {
|
private void persistFiles() {
|
||||||
location.delete()
|
location.delete()
|
||||||
def sharedFiles = fileSource.getSharedFiles()
|
def sharedFiles = fileSource.getSharedFiles()
|
||||||
|
location.withPrintWriter { writer ->
|
||||||
sharedFiles.each { k, v ->
|
sharedFiles.each { k, v ->
|
||||||
def json = toJson(k,v)
|
def json = toJson(k,v)
|
||||||
json = JsonOutput.toJson(json)
|
json = JsonOutput.toJson(json)
|
||||||
location.append "$json\n"
|
writer.println json
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -107,13 +107,15 @@ class HostCache extends Service {
|
|||||||
|
|
||||||
private void save() {
|
private void save() {
|
||||||
storage.delete()
|
storage.delete()
|
||||||
|
storage.withPrintWriter { writer ->
|
||||||
hosts.each { dest, host ->
|
hosts.each { dest, host ->
|
||||||
if (allowHost(host)) {
|
if (allowHost(host)) {
|
||||||
def map = [:]
|
def map = [:]
|
||||||
map.destination = dest.toBase64()
|
map.destination = dest.toBase64()
|
||||||
map.failures = host.failures
|
map.failures = host.failures
|
||||||
def json = JsonOutput.toJson(map)
|
def json = JsonOutput.toJson(map)
|
||||||
storage.append("${json}\n")
|
writer.println json
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,12 +49,16 @@ class TrustService extends Service {
|
|||||||
|
|
||||||
private void persist() {
|
private void persist() {
|
||||||
persistGood.delete()
|
persistGood.delete()
|
||||||
|
persistGood.withPrintWriter { writer ->
|
||||||
good.each {
|
good.each {
|
||||||
persistGood.append("${it.toBase64()}\n")
|
writer.println it.toBase64()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
persistBad.delete()
|
persistBad.delete()
|
||||||
|
persistBad.withPrintWriter { writer ->
|
||||||
bad.each {
|
bad.each {
|
||||||
persistBad.append("${it.toBase64()}\n")
|
writer.println it.toBase64()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user