Loading java/src/com/android/inputmethod/latin/makedict/DictDecoder.java +4 −1 Original line number Diff line number Diff line Loading @@ -54,10 +54,13 @@ public interface DictDecoder { * which words from the buffer should be added. If it is null, a new dictionary is created. * * @param dict an optional dictionary to add words to, or null. * @param deleteDictIfBroken a flag indicating whether this method should remove the broken * dictionary or not. * @return the created (or merged) dictionary. */ @UsedForTesting public FusionDictionary readDictionaryBinary(final FusionDictionary dict) public FusionDictionary readDictionaryBinary(final FusionDictionary dict, final boolean deleteDictIfBroken) throws FileNotFoundException, IOException, UnsupportedFormatException; /** Loading java/src/com/android/inputmethod/latin/makedict/Ver3DictDecoder.java +4 −3 Original line number Diff line number Diff line Loading @@ -306,7 +306,8 @@ public class Ver3DictDecoder implements DictDecoder { } @Override public FusionDictionary readDictionaryBinary(final FusionDictionary dict) public FusionDictionary readDictionaryBinary(final FusionDictionary dict, final boolean deleteDictIfBroken) throws FileNotFoundException, IOException, UnsupportedFormatException { if (mDictBuffer == null) { openDictBuffer(); Loading @@ -315,13 +316,13 @@ public class Ver3DictDecoder implements DictDecoder { return BinaryDictDecoderUtils.readDictionaryBinary(this, dict); } catch (IOException e) { Log.e(TAG, "The dictionary " + mDictionaryBinaryFile.getName() + " is broken.", e); if (!mDictionaryBinaryFile.delete()) { if (deleteDictIfBroken && !mDictionaryBinaryFile.delete()) { Log.e(TAG, "Failed to delete the broken dictionary."); } throw e; } catch (UnsupportedFormatException e) { Log.e(TAG, "The dictionary " + mDictionaryBinaryFile.getName() + " is broken.", e); if (!mDictionaryBinaryFile.delete()) { if (deleteDictIfBroken && !mDictionaryBinaryFile.delete()) { Log.e(TAG, "Failed to delete the broken dictionary."); } throw e; Loading tests/src/com/android/inputmethod/latin/makedict/BinaryDictDecoderEncoderTests.java +1 −1 Original line number Diff line number Diff line Loading @@ -289,7 +289,7 @@ public class BinaryDictDecoderEncoderTests extends AndroidTestCase { dictDecoder.openDictBuffer(); assertNotNull(dictDecoder.getDictBuffer()); now = System.currentTimeMillis(); dict = dictDecoder.readDictionaryBinary(null); dict = dictDecoder.readDictionaryBinary(null, false /* deleteDictIfBroken */); diff = System.currentTimeMillis() - now; } catch (IOException e) { Log.e(TAG, "IOException while reading dictionary", e); Loading tools/dicttool/src/com/android/inputmethod/latin/dicttool/BinaryDictOffdeviceUtils.java +1 −1 Original line number Diff line number Diff line Loading @@ -192,7 +192,7 @@ public final class BinaryDictOffdeviceUtils { System.out.println("Packaging : " + decodedSpec.describeChain()); System.out.println("Uncompressed size : " + decodedSpec.mFile.length()); } return dictDecoder.readDictionaryBinary(null); return dictDecoder.readDictionaryBinary(null, false /* deleteDictIfBroken */); } } } catch (IOException e) { Loading tools/dicttool/src/com/android/inputmethod/latin/dicttool/DictionaryMaker.java +1 −1 Original line number Diff line number Diff line Loading @@ -268,7 +268,7 @@ public class DictionaryMaker { throws FileNotFoundException, IOException, UnsupportedFormatException { final File file = new File(binaryFilename); final DictDecoder dictDecoder = new Ver3DictDecoder(file); return dictDecoder.readDictionaryBinary(null); return dictDecoder.readDictionaryBinary(null, false /* deleteDictIfBroken */); } /** Loading Loading
java/src/com/android/inputmethod/latin/makedict/DictDecoder.java +4 −1 Original line number Diff line number Diff line Loading @@ -54,10 +54,13 @@ public interface DictDecoder { * which words from the buffer should be added. If it is null, a new dictionary is created. * * @param dict an optional dictionary to add words to, or null. * @param deleteDictIfBroken a flag indicating whether this method should remove the broken * dictionary or not. * @return the created (or merged) dictionary. */ @UsedForTesting public FusionDictionary readDictionaryBinary(final FusionDictionary dict) public FusionDictionary readDictionaryBinary(final FusionDictionary dict, final boolean deleteDictIfBroken) throws FileNotFoundException, IOException, UnsupportedFormatException; /** Loading
java/src/com/android/inputmethod/latin/makedict/Ver3DictDecoder.java +4 −3 Original line number Diff line number Diff line Loading @@ -306,7 +306,8 @@ public class Ver3DictDecoder implements DictDecoder { } @Override public FusionDictionary readDictionaryBinary(final FusionDictionary dict) public FusionDictionary readDictionaryBinary(final FusionDictionary dict, final boolean deleteDictIfBroken) throws FileNotFoundException, IOException, UnsupportedFormatException { if (mDictBuffer == null) { openDictBuffer(); Loading @@ -315,13 +316,13 @@ public class Ver3DictDecoder implements DictDecoder { return BinaryDictDecoderUtils.readDictionaryBinary(this, dict); } catch (IOException e) { Log.e(TAG, "The dictionary " + mDictionaryBinaryFile.getName() + " is broken.", e); if (!mDictionaryBinaryFile.delete()) { if (deleteDictIfBroken && !mDictionaryBinaryFile.delete()) { Log.e(TAG, "Failed to delete the broken dictionary."); } throw e; } catch (UnsupportedFormatException e) { Log.e(TAG, "The dictionary " + mDictionaryBinaryFile.getName() + " is broken.", e); if (!mDictionaryBinaryFile.delete()) { if (deleteDictIfBroken && !mDictionaryBinaryFile.delete()) { Log.e(TAG, "Failed to delete the broken dictionary."); } throw e; Loading
tests/src/com/android/inputmethod/latin/makedict/BinaryDictDecoderEncoderTests.java +1 −1 Original line number Diff line number Diff line Loading @@ -289,7 +289,7 @@ public class BinaryDictDecoderEncoderTests extends AndroidTestCase { dictDecoder.openDictBuffer(); assertNotNull(dictDecoder.getDictBuffer()); now = System.currentTimeMillis(); dict = dictDecoder.readDictionaryBinary(null); dict = dictDecoder.readDictionaryBinary(null, false /* deleteDictIfBroken */); diff = System.currentTimeMillis() - now; } catch (IOException e) { Log.e(TAG, "IOException while reading dictionary", e); Loading
tools/dicttool/src/com/android/inputmethod/latin/dicttool/BinaryDictOffdeviceUtils.java +1 −1 Original line number Diff line number Diff line Loading @@ -192,7 +192,7 @@ public final class BinaryDictOffdeviceUtils { System.out.println("Packaging : " + decodedSpec.describeChain()); System.out.println("Uncompressed size : " + decodedSpec.mFile.length()); } return dictDecoder.readDictionaryBinary(null); return dictDecoder.readDictionaryBinary(null, false /* deleteDictIfBroken */); } } } catch (IOException e) { Loading
tools/dicttool/src/com/android/inputmethod/latin/dicttool/DictionaryMaker.java +1 −1 Original line number Diff line number Diff line Loading @@ -268,7 +268,7 @@ public class DictionaryMaker { throws FileNotFoundException, IOException, UnsupportedFormatException { final File file = new File(binaryFilename); final DictDecoder dictDecoder = new Ver3DictDecoder(file); return dictDecoder.readDictionaryBinary(null); return dictDecoder.readDictionaryBinary(null, false /* deleteDictIfBroken */); } /** Loading