Simplification

pull/190/head
M66B 4 years ago
parent bc917dedb5
commit 59d85f25bd

@ -33,7 +33,6 @@ import androidx.work.Worker;
import androidx.work.WorkerParameters; import androidx.work.WorkerParameters;
import java.io.File; import java.io.File;
import java.io.FileNotFoundException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
@ -66,11 +65,13 @@ public class WorkerFts extends Worker {
SQLiteDatabase sdb = FtsDbHelper.getInstance(context); SQLiteDatabase sdb = FtsDbHelper.getInstance(context);
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
try (Cursor cursor = db.message().getMessageFts()) { try (Cursor cursor = db.message().getMessageFts()) {
while (cursor.moveToNext()) { while (cursor.moveToNext())
long id = cursor.getLong(0);
try { try {
long id = cursor.getLong(0);
Log.i("FTS index=" + id); Log.i("FTS index=" + id);
ids.add(id);
EntityMessage message = db.message().getMessage(id); EntityMessage message = db.message().getMessage(id);
if (message == null) { if (message == null) {
Log.i("FTS gone"); Log.i("FTS gone");
@ -98,16 +99,11 @@ public class WorkerFts extends Worker {
indexed++; indexed++;
ids.add(id);
if (ids.size() > INDEX_BATCH_SIZE) if (ids.size() > INDEX_BATCH_SIZE)
markIndexed(db, ids); markIndexed(db, ids);
} catch (Throwable ex) { } catch (Throwable ex) {
if (ex instanceof FileNotFoundException ||
ex instanceof OutOfMemoryError)
ids.add(id);
Log.e(ex); Log.e(ex);
} }
}
markIndexed(db, ids); markIndexed(db, ids);
} }

Loading…
Cancel
Save