From 8aa2be2b05a732986fc85ed81a050be4c1a3045a Mon Sep 17 00:00:00 2001 From: Hardcore Sushi Date: Fri, 22 Apr 2022 12:12:57 +0200 Subject: [PATCH] Update libgocryptfs & Small UX fix --- app/build.gradle | 4 +- app/libgocryptfs | 2 +- .../sushi/hardcore/droidfs/GocryptfsVolume.kt | 38 +++++++++---------- .../sushi/hardcore/droidfs/MainActivity.kt | 3 +- 4 files changed, 21 insertions(+), 26 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 9161b20..7d098aa 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -15,8 +15,8 @@ android { minSdkVersion 21 //noinspection ExpiredTargetSdkVersion targetSdkVersion 29 - versionCode 26 - versionName "1.10.0" + versionCode 27 + versionName "1.10.1" ndk { abiFilters "x86", "x86_64", "armeabi-v7a", "arm64-v8a" diff --git a/app/libgocryptfs b/app/libgocryptfs index 985d852..9e98192 160000 --- a/app/libgocryptfs +++ b/app/libgocryptfs @@ -1 +1 @@ -Subproject commit 985d8523434814cd9cba61b666a1f888bdcbaded +Subproject commit 9e98192442b08362660b45f4e2e50221ba7bc65b diff --git a/app/src/main/java/sushi/hardcore/droidfs/GocryptfsVolume.kt b/app/src/main/java/sushi/hardcore/droidfs/GocryptfsVolume.kt index c2f4224..e85555e 100644 --- a/app/src/main/java/sushi/hardcore/droidfs/GocryptfsVolume.kt +++ b/app/src/main/java/sushi/hardcore/droidfs/GocryptfsVolume.kt @@ -141,32 +141,28 @@ class GocryptfsVolume(val applicationContext: Context, var sessionID: Int) { return false } - fun importFile(inputStream: InputStream, handleID: Int): Boolean { - var offset: Long = 0 - val ioBuffer = ByteArray(DefaultBS) - var length: Int - while (inputStream.read(ioBuffer).also { length = it } > 0) { - val written = writeFile(handleID, offset, ioBuffer, length).toLong() - if (written == length.toLong()) { - offset += written - } else { - inputStream.close() - return false - } - } - closeFile(handleID) - inputStream.close() - return true - } - fun importFile(inputStream: InputStream, dst_path: String): Boolean { - var success = false val dstHandleId = openWriteMode(dst_path) if (dstHandleId != -1) { - success = importFile(inputStream, dstHandleId) + var success = true + var offset: Long = 0 + val ioBuffer = ByteArray(DefaultBS) + var length: Int + while (inputStream.read(ioBuffer).also { length = it } > 0) { + val written = writeFile(dstHandleId, offset, ioBuffer, length).toLong() + if (written == length.toLong()) { + offset += written + } else { + inputStream.close() + success = false + break + } + } closeFile(dstHandleId) + inputStream.close() + return success } - return success + return false } fun importFile(context: Context, src_uri: Uri, dst_path: String): Boolean { diff --git a/app/src/main/java/sushi/hardcore/droidfs/MainActivity.kt b/app/src/main/java/sushi/hardcore/droidfs/MainActivity.kt index 37aa014..770228a 100644 --- a/app/src/main/java/sushi/hardcore/droidfs/MainActivity.kt +++ b/app/src/main/java/sushi/hardcore/droidfs/MainActivity.kt @@ -594,8 +594,7 @@ class MainActivity : BaseActivity(), VolumeAdapter.Listener { CustomAlertDialogBuilder(this, themeValue) .setTitle(R.string.open_volume_failed) .setMessage(R.string.open_volume_failed_msg) - .setPositiveButton(R.string.ok, null) - .setOnDismissListener { + .setPositiveButton(R.string.ok) { _, _ -> askForPassword(volume, position, savePasswordHash) } .show()