delete dict if there's an IO error while writing it. A German

correspondent's having occasional crashes with a single dictionary.
It appears that if it were truncated during the download that it would
appear ok until a word search spread into a missing area.  This fix is
untested, and should probably be replaced by a checksum that computed
and checked after the download, but I think it's an improvement.
This commit is contained in:
Eric House 2011-02-08 21:18:51 -08:00
parent a2ad3d7c0b
commit dada74aad7

View file

@ -319,7 +319,6 @@ public class GameUtils {
public static void saveDict( Context context, String name, InputStream in )
{
int totalRead = 0;
try {
FileOutputStream fos = context.openFileOutput( name,
Context.MODE_PRIVATE );
@ -327,13 +326,13 @@ public class GameUtils {
int nRead;
while( 0 <= (nRead = in.read( buf, 0, buf.length )) ) {
fos.write( buf, 0, nRead );
totalRead += nRead;
}
fos.close();
} catch ( java.io.FileNotFoundException fnf ) {
Utils.logf( "saveDict: FileNotFoundException: %s", fnf.toString() );
} catch ( java.io.IOException ioe ) {
Utils.logf( "saveDict: IOException: %s", ioe.toString() );
deleteDict( context, name );
}
}