include len in info for upgradeable wordlists

Server should offer to upgrade if size has changed: checksum doesn't
cover everything.
This commit is contained in:
Eric House 2020-05-02 13:04:32 -07:00
parent 67f74b3808
commit 2b8e6e192a
3 changed files with 16 additions and 0 deletions

View file

@ -34,6 +34,7 @@ import org.eehouse.android.xw4.jni.JNIUtilsImpl;
import org.eehouse.android.xw4.jni.XwJNI;
import org.eehouse.android.xw4.loc.LocUtils;
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
@ -299,6 +300,12 @@ public class DictLangCache {
return result;
}
public static long getFileLen( Context context, DictAndLoc dal )
{
File path = dal.getPath( context );
return path.length();
}
public static int getDictLangCode( Context context, String dict )
{
return getInfo( context, dict ).langCode;

View file

@ -117,6 +117,12 @@ public class DictUtils {
public String name;
public DictLoc loc;
public File getPath( Context context )
{
File path = getDictFile( context, addDictExtn(name), loc );
return path;
}
@Override
public boolean equals( Object obj )
{

View file

@ -62,6 +62,7 @@ public class UpdateCheckReceiver extends BroadcastReceiver {
private static final String k_LANG = "lang";
private static final String k_MD5SUM = "md5sum";
private static final String k_INDEX = "index";
private static final String k_LEN = "len";
private static final String k_URL = "url";
private static final String k_DEVID = "did";
private static final String k_DEBUG = "dbg";
@ -215,11 +216,13 @@ public class UpdateCheckReceiver extends BroadcastReceiver {
int lang = DictLangCache.getDictLangCode( context, dal );
String langStr = DictLangCache.getLangName( context, lang );
String sum = DictLangCache.getDictMD5Sum( context, dal.name );
long len = DictLangCache.getFileLen( context, dal );
try {
params.put( k_NAME, dal.name );
params.put( k_LANG, langStr );
params.put( k_MD5SUM, sum );
params.put( k_INDEX, index );
params.put( k_LEN, len );
} catch( org.json.JSONException jse ) {
Log.ex( TAG, jse );
}