Show a toast when EACCESS from backing up - 1.133
I don't like having a bunch of backups saying massive (x).db. Also this masks the issue of permissions, which is easily fixed by deleting/moving the old massive.db.
This commit is contained in:
parent
d2a1c432bb
commit
0e7920bde9
|
@ -41,8 +41,8 @@ android {
|
||||||
missingDimensionStrategy "RNNotifications.reactNativeVersion", "reactNative60"
|
missingDimensionStrategy "RNNotifications.reactNativeVersion", "reactNative60"
|
||||||
minSdkVersion rootProject.ext.minSdkVersion
|
minSdkVersion rootProject.ext.minSdkVersion
|
||||||
targetSdkVersion rootProject.ext.targetSdkVersion
|
targetSdkVersion rootProject.ext.targetSdkVersion
|
||||||
versionCode 36158
|
versionCode 36159
|
||||||
versionName "1.132"
|
versionName "1.133"
|
||||||
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
|
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
|
||||||
|
|
||||||
if (isNewArchitectureEnabled()) {
|
if (isNewArchitectureEnabled()) {
|
||||||
|
|
|
@ -10,6 +10,7 @@ import android.content.IntentFilter
|
||||||
import android.content.pm.PackageManager
|
import android.content.pm.PackageManager
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.os.Environment
|
import android.os.Environment
|
||||||
|
import android.widget.Toast
|
||||||
import androidx.annotation.RequiresApi
|
import androidx.annotation.RequiresApi
|
||||||
import androidx.core.app.ActivityCompat
|
import androidx.core.app.ActivityCompat
|
||||||
import com.facebook.react.bridge.ReactApplicationContext
|
import com.facebook.react.bridge.ReactApplicationContext
|
||||||
|
@ -32,8 +33,7 @@ class BackupModule constructor(context: ReactApplicationContext?) :
|
||||||
val sourceFile = File(context?.getDatabasePath("massive.db")!!.path)
|
val sourceFile = File(context?.getDatabasePath("massive.db")!!.path)
|
||||||
val targetDir =
|
val targetDir =
|
||||||
Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS)
|
Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS)
|
||||||
var targetFile = File(targetDir, "massive.db")
|
val targetFile = File(targetDir, "massive.db")
|
||||||
var count = 0
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
val input = FileInputStream(sourceFile)
|
val input = FileInputStream(sourceFile)
|
||||||
|
@ -42,15 +42,11 @@ class BackupModule constructor(context: ReactApplicationContext?) :
|
||||||
input.close()
|
input.close()
|
||||||
output.close()
|
output.close()
|
||||||
} catch (e: IOException) {
|
} catch (e: IOException) {
|
||||||
while (targetFile.exists()) {
|
Toast.makeText(
|
||||||
count++
|
reactApplicationContext,
|
||||||
targetFile = File(targetDir, "massive (${count}).db")
|
"Access to massive.db is denied. Try deleting it first.",
|
||||||
}
|
Toast.LENGTH_LONG
|
||||||
val input = FileInputStream(sourceFile)
|
).show()
|
||||||
val output = FileOutputStream(targetFile)
|
|
||||||
input.copyTo(output)
|
|
||||||
input.close()
|
|
||||||
output.close()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "massive",
|
"name": "massive",
|
||||||
"version": "1.132",
|
"version": "1.133",
|
||||||
"private": true,
|
"private": true,
|
||||||
"license": "GPL-3.0-only",
|
"license": "GPL-3.0-only",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user