From 0e7920bde96ca06bb1333dcee8100dce682630cb Mon Sep 17 00:00:00 2001 From: Brandon Presley Date: Fri, 24 Mar 2023 17:47:03 +1300 Subject: [PATCH] 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. --- android/app/build.gradle | 4 ++-- .../src/main/java/com/massive/BackupModule.kt | 18 +++++++----------- package.json | 2 +- 3 files changed, 10 insertions(+), 14 deletions(-) diff --git a/android/app/build.gradle b/android/app/build.gradle index 9bc6425..58bb8bb 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -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()) { diff --git a/android/app/src/main/java/com/massive/BackupModule.kt b/android/app/src/main/java/com/massive/BackupModule.kt index 1b84241..01828ef 100644 --- a/android/app/src/main/java/com/massive/BackupModule.kt +++ b/android/app/src/main/java/com/massive/BackupModule.kt @@ -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() } } } diff --git a/package.json b/package.json index 03c8082..a53a050 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "massive", - "version": "1.132", + "version": "1.133", "private": true, "license": "GPL-3.0-only", "scripts": {