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