MCPcopy Create free account
hub / github.com/M66B/FairEmail / checkpoint

Method checkpoint

app/src/main/java/eu/faircode/email/DB.java:3177–3206  ·  view source on GitHub ↗
(Context context)

Source from the content-addressed store, hash-verified

3175 }
3176
3177 public static void checkpoint(Context context) {
3178 // https://www.sqlite.org/pragma.html#pragma_wal_checkpoint
3179 DB db = getInstance(context);
3180 db.getQueryExecutor().execute(new Runnable() {
3181 @Override
3182 public void run() {
3183 try {
3184 long start = new Date().getTime();
3185 StringBuilder sb = new StringBuilder();
3186 SupportSQLiteDatabase sdb = db.getOpenHelper().getWritableDatabase();
3187 String mode = (true ? "RESTART" : "PASSIVE");
3188 try (Cursor cursor = sdb.query("PRAGMA wal_checkpoint(" + mode + ");")) {
3189 if (cursor.moveToNext()) {
3190 for (int i = 0; i < cursor.getColumnCount(); i++) {
3191 if (i > 0)
3192 sb.append(",");
3193 sb.append(cursor.getInt(i));
3194 }
3195 }
3196 }
3197
3198 long elapse = new Date().getTime() - start;
3199 EntityLog.log(context, "PRAGMA wal_checkpoint(" + mode + ")=" + sb +
3200 " elapse=" + elapse + " ms");
3201 } catch (Throwable ex) {
3202 Log.e(ex);
3203 }
3204 }
3205 });
3206 }
3207
3208 public static void shrinkMemory(Context context) {
3209 DB db = getInstance(context);

Callers 1

doWorkMethod · 0.95

Calls 3

getInstanceMethod · 0.95
executeMethod · 0.45
getQueryExecutorMethod · 0.45

Tested by

no test coverage detected