diff --git a/auto-cream-api.iml b/auto-cream-api.iml index 4599ba8..f79f6a4 100644 --- a/auto-cream-api.iml +++ b/auto-cream-api.iml @@ -1,5 +1,10 @@ + + + diff --git a/src/main/java/util/SteamAppsListCache.java b/src/main/java/util/SteamAppsListCache.java index 3e107a6..037dd52 100644 --- a/src/main/java/util/SteamAppsListCache.java +++ b/src/main/java/util/SteamAppsListCache.java @@ -1,6 +1,7 @@ package util; import com.google.gson.Gson; +import com.google.gson.JsonSyntaxException; import com.google.gson.reflect.TypeToken; import kong.unirest.HttpResponse; import kong.unirest.Unirest; @@ -47,6 +48,10 @@ public class SteamAppsListCache { System.err.println("File does not exist, trying to create steamapps.json for the first time..."); //fileFound = false; sync(); + } catch (JsonSyntaxException e) { + System.err.println("File seems to be corrupt, trying to recreate steamapps.json..."); + //fileFound = false; + sync(); } if (Instant.now().isAfter(list.getTimestamp().plus(Duration.ofDays(3)))) { System.err.println("List in file is not recent!"); @@ -115,7 +120,7 @@ public class SteamAppsListCache { System.out.println("Successfully saved SteamAppList to file (" + cacheFile.getAbsolutePath() + ")..."); } - private void getListFromFile() throws FileNotFoundException { + private void getListFromFile() throws FileNotFoundException, JsonSyntaxException { System.out.println("Trying to get SteamAppList from file (" + cacheFile.getAbsolutePath() + ")..."); BufferedReader fIn = new BufferedReader(new FileReader(cacheFile)); String json = fIn.lines().collect(Collectors.joining());