From a4a21904eddd61d34254c80071fa08f70b85d1d1 Mon Sep 17 00:00:00 2001 From: carbotaniuman <41451839+carbotaniuman@users.noreply.github.com> Date: Sat, 13 Jun 2020 16:10:17 -0500 Subject: [PATCH] Fix saving --- src/main/java/mdnet/base/MangaDexClient.java | 21 ++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/main/java/mdnet/base/MangaDexClient.java b/src/main/java/mdnet/base/MangaDexClient.java index de38140..1ec64be 100644 --- a/src/main/java/mdnet/base/MangaDexClient.java +++ b/src/main/java/mdnet/base/MangaDexClient.java @@ -84,16 +84,6 @@ public class MangaDexClient { } statsMap.put(Instant.now(), statistics.get()); - try { - DiskLruCache.Editor editor = cache.edit("statistics"); - if (editor != null) { - String json = GSON.toJson(statistics.get(), Statistics.class); - editor.setString(0, json); - editor.setString(1, ""); - editor.setString(2, ""); - editor.commit(); - } - } catch (IOException ignored) {} if (clientSettings.getWebSettings() != null) { webUi = WebUiKt.getUiServer(clientSettings.getWebSettings(), statistics, statsMap); @@ -122,6 +112,17 @@ public class MangaDexClient { statsMap.put(Instant.now(), statistics.get()); + try { + DiskLruCache.Editor editor = cache.edit("statistics"); + if (editor != null) { + String json = GSON.toJson(statistics.get(), Statistics.class); + editor.setString(0, json); + editor.setString(1, ""); + editor.setString(2, ""); + editor.commit(); + } + } catch (IOException ignored) {} + // if the server is offline then don't try and refresh certs if (engine == null) { return;