@@ -155,27 +155,29 @@ private static void deepMergeInto(JSONObject oldJSON, JSONObject newJSON)
155
155
* a "checkpoint" and is done automatically (by default) when the WAL file reaches a threshold
156
156
* size of 1000 pages.
157
157
* More here: https://sqlite.org/wal.html
158
- * <p>
158
+ *
159
159
* This helper will force checkpoint on RKStorage, if Next storage file does not exists yet.
160
160
*/
161
161
public static void verifyAndForceSqliteCheckpoint (Context ctx ) {
162
+ if (Build .VERSION .SDK_INT < Build .VERSION_CODES .P ) {
163
+ Log .i ("AsyncStorage_Next" , "SQLite checkpoint not required on this API version." );
164
+ }
165
+
162
166
File nextStorageFile = ctx .getDatabasePath ("AsyncStorage" );
163
167
File currentStorageFile = ctx .getDatabasePath (ReactDatabaseSupplier .DATABASE_NAME );
164
- boolean isCheckpointRequired = Build .VERSION .SDK_INT >= Build .VERSION_CODES .P
165
- && !nextStorageFile .exists ()
166
- && currentStorageFile .exists ();
168
+ boolean isCheckpointRequired = !nextStorageFile .exists () && currentStorageFile .exists ();
167
169
if (!isCheckpointRequired ) {
168
170
Log .i ("AsyncStorage_Next" , "SQLite checkpoint not required." );
169
171
return ;
170
172
}
171
173
172
174
try {
173
175
ReactDatabaseSupplier supplier = ReactDatabaseSupplier .getInstance (ctx );
174
- supplier .get ().execSQL ("PRAGMA wal_checkpoint" );
176
+ supplier .get ().rawQuery ("PRAGMA wal_checkpoint" , null ). close ( );
175
177
supplier .closeDatabase ();
176
178
Log .i ("AsyncStorage_Next" , "Forcing SQLite checkpoint successful." );
177
179
} catch (Exception e ) {
178
- Log .w ("AsyncStorage_Next" , "Could not force checkpoint on RKStorage: " + e .getMessage ());
180
+ Log .w ("AsyncStorage_Next" , "Could not force checkpoint on RKStorage, the Next storage might not migrate the data properly : " + e .getMessage ());
179
181
}
180
182
}
181
183
}
0 commit comments