diff options
author | 2013-09-11 12:08:19 +0900 | |
---|---|---|
committer | 2013-09-11 18:20:56 +0900 | |
commit | 95bc256f419e9e47c26dfefd1ac31266dac2f344 (patch) | |
tree | b2ac52987e300b226a9101fb6606bff7c91c5762 /java/src | |
parent | f7ec77fe2f66e946040d11f2936fb8559e709848 (diff) | |
download | latinime-95bc256f419e9e47c26dfefd1ac31266dac2f344.tar.gz latinime-95bc256f419e9e47c26dfefd1ac31266dac2f344.tar.xz latinime-95bc256f419e9e47c26dfefd1ac31266dac2f344.zip |
Add a flag to readDictioanryBinary in DictDecoder.
Change-Id: I356adb72047ebc43c924fbff1ff45e7460508a31
Diffstat (limited to 'java/src')
-rw-r--r-- | java/src/com/android/inputmethod/latin/makedict/DictDecoder.java | 5 | ||||
-rw-r--r-- | java/src/com/android/inputmethod/latin/makedict/Ver3DictDecoder.java | 7 |
2 files changed, 8 insertions, 4 deletions
diff --git a/java/src/com/android/inputmethod/latin/makedict/DictDecoder.java b/java/src/com/android/inputmethod/latin/makedict/DictDecoder.java index 11a3f0b3a..64638fd98 100644 --- a/java/src/com/android/inputmethod/latin/makedict/DictDecoder.java +++ b/java/src/com/android/inputmethod/latin/makedict/DictDecoder.java @@ -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; /** diff --git a/java/src/com/android/inputmethod/latin/makedict/Ver3DictDecoder.java b/java/src/com/android/inputmethod/latin/makedict/Ver3DictDecoder.java index 1a5023ef6..b98aa0f60 100644 --- a/java/src/com/android/inputmethod/latin/makedict/Ver3DictDecoder.java +++ b/java/src/com/android/inputmethod/latin/makedict/Ver3DictDecoder.java @@ -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(); @@ -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; |