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:
Brandon Presley 2023-03-24 17:47:03 +13:00
parent d2a1c432bb
commit 0e7920bde9
3 changed files with 10 additions and 14 deletions

View File

@ -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()) {

View File

@ -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()
}
}
}

View File

@ -1,6 +1,6 @@
{
"name": "massive",
"version": "1.132",
"version": "1.133",
"private": true,
"license": "GPL-3.0-only",
"scripts": {