mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-30 08:34:16 +01:00
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:
parent
a2ad3d7c0b
commit
dada74aad7
1 changed files with 1 additions and 2 deletions
|
@ -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 );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue