Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a9b2be8a authored by Tom Ouyang's avatar Tom Ouyang
Browse files

Change expandable binary dict write to a temp file first.

Bug: 6380724
Change-Id: Ic1d0d902dc45ecb41a1792f33a60ab85e606fcef
parent 7f45ec7b
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -288,13 +288,16 @@ abstract public class ExpandableBinaryDictionary extends Dictionary {

        loadDictionaryAsync();

        final String tempFileName = mFilename + ".temp";
        final File file = new File(mContext.getFilesDir(), mFilename);
        final File tempFile = new File(mContext.getFilesDir(), tempFileName);
        FileOutputStream out = null;
        try {
            out = new FileOutputStream(file);
            out = new FileOutputStream(tempFile);
            BinaryDictInputOutput.writeDictionaryBinary(out, mFusionDictionary, 1);
            out.flush();
            out.close();
            tempFile.renameTo(file);
            clearFusionDictionary();
        } catch (IOException e) {
            Log.e(TAG, "IO exception while writing file: " + e);