refactor checkpointing
This commit is contained in:
parent
c6b062a698
commit
3e1e07e468
2 changed files with 14 additions and 10 deletions
|
|
@ -1,8 +1,10 @@
|
|||
package org.schabi.newpipe;
|
||||
|
||||
import androidx.room.Room;
|
||||
import android.content.Context;
|
||||
import android.database.Cursor;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.room.Room;
|
||||
|
||||
import org.schabi.newpipe.database.AppDatabase;
|
||||
|
||||
|
|
@ -39,4 +41,14 @@ public final class NewPipeDatabase {
|
|||
|
||||
return result;
|
||||
}
|
||||
|
||||
public static void checkpoint() {
|
||||
if(null == databaseInstance){
|
||||
throw new IllegalStateException("database is not initialized");
|
||||
}
|
||||
Cursor c = databaseInstance.query("pragma wal_checkpoint(full)", null);
|
||||
if(c.moveToFirst() && c.getInt(0) == 1) {
|
||||
throw new RuntimeException("Checkpoint was blocked from completing");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue