|
@@ -4,6 +4,7 @@ import { Asset } from 'expo-asset';
|
|
import { API_HOST } from 'src/constants';
|
|
import { API_HOST } from 'src/constants';
|
|
import { storage } from 'src/storage';
|
|
import { storage } from 'src/storage';
|
|
import { fetchLastDareDbUpdate, fetchLastRegionsDbUpdate } from '@api/app';
|
|
import { fetchLastDareDbUpdate, fetchLastRegionsDbUpdate } from '@api/app';
|
|
|
|
+import NetInfo from '@react-native-community/netinfo';
|
|
|
|
|
|
let db1: SQLite.SQLiteDatabase | null = null;
|
|
let db1: SQLite.SQLiteDatabase | null = null;
|
|
let db2: SQLite.SQLiteDatabase | null = null;
|
|
let db2: SQLite.SQLiteDatabase | null = null;
|
|
@@ -16,6 +17,10 @@ const sqliteFullPath = FileSystem.documentDirectory + sqliteDirectory;
|
|
const DS = '/';
|
|
const DS = '/';
|
|
|
|
|
|
async function copyDatabaseFile(dbName: string, dbAsset: Asset) {
|
|
async function copyDatabaseFile(dbName: string, dbAsset: Asset) {
|
|
|
|
+ const state = await NetInfo.fetch();
|
|
|
|
+
|
|
|
|
+ if (!state.isConnected && !state.isInternetReachable) return;
|
|
|
|
+
|
|
console.log('DB copy start - ' + dbName);
|
|
console.log('DB copy start - ' + dbName);
|
|
await dbAsset.downloadAsync();
|
|
await dbAsset.downloadAsync();
|
|
await FileSystem.downloadAsync(dbAsset.uri, sqliteFullPath + DS + dbName);
|
|
await FileSystem.downloadAsync(dbAsset.uri, sqliteFullPath + DS + dbName);
|