mirror of
https://github.com/EarthMC/QuickShop-Reremake.git
synced 2026-11-25 09:59:49 -05:00
Fix resource leaking and bug in MojangGameLanguageImpl
This commit is contained in:
1 parent
9f3e2a9af6
commit
89ae0fde90
1 file changed
+10
-9
+10
-9
@@ -238,15 +238,16 @@ public class MojangGameLanguageImpl extends BukkitGameLanguageImpl implements Ga
|
||||
File cachedFile = new File(Util.getCacheFolder(), cacheSha1);
|
||||
if (languageCode.equals(cacheCode)) { //Language same
|
||||
if (cachedFile.exists()) { //File exists
|
||||
if (DigestUtils.sha1Hex(new FileInputStream(cachedFile)).equals(cacheSha1)) { //Check if file broken
|
||||
//noinspection EqualsWithItself
|
||||
if (cacheVersion.equals(cacheVersion)) {
|
||||
isLatest = true;
|
||||
try (FileReader reader = new FileReader(cachedFile)) {
|
||||
lang = new JsonParser().parse(reader).getAsJsonObject();
|
||||
return; //We doesn't need to update it
|
||||
} catch (Exception e) {
|
||||
//Keep it empty so continue to update files
|
||||
try (FileInputStream cacheFileInputSteam = new FileInputStream(cachedFile)) {
|
||||
if (DigestUtils.sha1Hex(cacheFileInputSteam).equals(cacheSha1)) { //Check if file broken
|
||||
if (cacheVersion.equals(ReflectFactory.getServerVersion())) {
|
||||
isLatest = true;
|
||||
try (FileReader reader = new FileReader(cachedFile)) {
|
||||
lang = new JsonParser().parse(reader).getAsJsonObject();
|
||||
return; //We doesn't need to update it
|
||||
} catch (Exception e) {
|
||||
//Keep it empty so continue to update files
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user