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"
|
||||
minSdkVersion rootProject.ext.minSdkVersion
|
||||
targetSdkVersion rootProject.ext.targetSdkVersion
|
||||
versionCode 36158
|
||||
versionName "1.132"
|
||||
versionCode 36159
|
||||
versionName "1.133"
|
||||
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
|
||||
|
||||
if (isNewArchitectureEnabled()) {
|
||||
|
|
|
@ -10,6 +10,7 @@ import android.content.IntentFilter
|
|||
import android.content.pm.PackageManager
|
||||
import android.os.Build
|
||||
import android.os.Environment
|
||||
import android.widget.Toast
|
||||
import androidx.annotation.RequiresApi
|
||||
import androidx.core.app.ActivityCompat
|
||||
import com.facebook.react.bridge.ReactApplicationContext
|
||||
|
@ -32,8 +33,7 @@ class BackupModule constructor(context: ReactApplicationContext?) :
|
|||
val sourceFile = File(context?.getDatabasePath("massive.db")!!.path)
|
||||
val targetDir =
|
||||
Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS)
|
||||
var targetFile = File(targetDir, "massive.db")
|
||||
var count = 0
|
||||
val targetFile = File(targetDir, "massive.db")
|
||||
|
||||
try {
|
||||
val input = FileInputStream(sourceFile)
|
||||
|
@ -42,15 +42,11 @@ class BackupModule constructor(context: ReactApplicationContext?) :
|
|||
input.close()
|
||||
output.close()
|
||||
} catch (e: IOException) {
|
||||
while (targetFile.exists()) {
|
||||
count++
|
||||
targetFile = File(targetDir, "massive (${count}).db")
|
||||
}
|
||||
val input = FileInputStream(sourceFile)
|
||||
val output = FileOutputStream(targetFile)
|
||||
input.copyTo(output)
|
||||
input.close()
|
||||
output.close()
|
||||
Toast.makeText(
|
||||
reactApplicationContext,
|
||||
"Access to massive.db is denied. Try deleting it first.",
|
||||
Toast.LENGTH_LONG
|
||||
).show()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "massive",
|
||||
"version": "1.132",
|
||||
"version": "1.133",
|
||||
"private": true,
|
||||
"license": "GPL-3.0-only",
|
||||
"scripts": {
|
||||
|
|
Loading…
Reference in New Issue
Block a user