@@ -96,9 +96,13 @@ public String getFile(String fileCrowdinPath, String crowdinLocale, boolean forc
9696 File metadataFile = new File (Util .getCacheFolder (), "i18n.metadata" );
9797 YamlConfiguration cacheMetadata = YamlConfiguration .loadConfiguration (metadataFile );
9898 long localeTimestamp = cacheMetadata .getLong (pathHash + ".timestamp" );
99- String data = Util .readToString (new File (Util .getCacheFolder (), pathHash ));
99+ File cachedDataFile = new File (Util .getCacheFolder (), pathHash );
100+ String data = null ;
101+ if (cachedDataFile .exists ()){
102+ data = Util .readToString (cachedDataFile );
103+ }
100104 // invalidate cache, flush it
101- if (localeTimestamp != manifest .getTimestamp () || forceFlush ) {
105+ if (forceFlush || data == null || localeTimestamp != manifest .getTimestamp ()) {
102106 String url = CROWDIN_OTA_HOST + "content/" + fileCrowdinPath .replace ("%locale%" , postProcessingPath );
103107 data = requestWithCache (url );
104108 if (data == null )
@@ -107,11 +111,11 @@ public String getFile(String fileCrowdinPath, String crowdinLocale, boolean forc
107111 cacheMetadata .set (pathHash + ".timestamp" , manifest .getTimestamp ());
108112 cacheMetadata .save (metadataFile );
109113 }
110- if (data == null ) {
111- cacheMetadata .set (pathHash , null );
112- cacheMetadata .save (metadataFile );
113- throw new IOException ("Couldn't read translation from local cache, please try again" );
114- }
114+ // if (data == null) {
115+ // cacheMetadata.set(pathHash, null);
116+ // cacheMetadata.save(metadataFile);
117+ // throw new IOException("Couldn't read translation from local cache, please try again");
118+ // }
115119 return data ;
116120 }
117121}
0 commit comments