aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHarsh Shandilya <me@msfjarvis.dev>2024-06-17 12:48:51 +0530
committerHarsh Shandilya <me@msfjarvis.dev>2024-07-28 23:00:16 +0530
commit9de25f751c4d992c749cb875f7bdbab2a66bfbee (patch)
tree2eaf714410e44d6e58b5ddbfb38f826e7559e043
parent0f7405a91aba244fef8c3cf176c94c1960c269e8 (diff)
fix: part 1 of NIO bugfixing
-rw-r--r--app/src/main/java/app/passwordstore/data/password/PasswordItem.kt3
-rw-r--r--app/src/main/java/app/passwordstore/ui/crypto/BasePGPActivity.kt4
2 files changed, 5 insertions, 2 deletions
diff --git a/app/src/main/java/app/passwordstore/data/password/PasswordItem.kt b/app/src/main/java/app/passwordstore/data/password/PasswordItem.kt
index 22f14a08..52ea6cd4 100644
--- a/app/src/main/java/app/passwordstore/data/password/PasswordItem.kt
+++ b/app/src/main/java/app/passwordstore/data/password/PasswordItem.kt
@@ -11,6 +11,7 @@ import app.passwordstore.ui.crypto.BasePGPActivity
import app.passwordstore.ui.main.LaunchActivity
import java.nio.file.Path
import kotlin.io.path.absolutePathString
+import kotlin.io.path.name
import kotlin.io.path.nameWithoutExtension
import kotlin.io.path.pathString
import kotlin.io.path.relativeTo
@@ -24,7 +25,7 @@ data class PasswordItem(
val name = file.nameWithoutExtension
- val fullPathToParent = file.relativeTo(rootDir).parent.pathString
+ val fullPathToParent = file.absolutePathString().replace(rootDir.absolutePathString(), "").replace(file.name, "")
val longName =
BasePGPActivity.getLongName(fullPathToParent, rootDir.absolutePathString(), toString())
diff --git a/app/src/main/java/app/passwordstore/ui/crypto/BasePGPActivity.kt b/app/src/main/java/app/passwordstore/ui/crypto/BasePGPActivity.kt
index dbeb86e4..ffec09ad 100644
--- a/app/src/main/java/app/passwordstore/ui/crypto/BasePGPActivity.kt
+++ b/app/src/main/java/app/passwordstore/ui/crypto/BasePGPActivity.kt
@@ -161,8 +161,10 @@ open class BasePGPActivity : AppCompatActivity() {
*/
fun getPGPIdentifiers(subDir: String): List<PGPIdentifier>? {
val repoRoot = PasswordRepository.getRepositoryDirectory()
+ // This should ideally be `repoRoot.resolve(subDir)` but for some reason doing that returns `/subDir` as the path
+ // which doesn't work inside `findTillRoot`, so we're doing this manual dance.
val gpgIdentifierFile =
- repoRoot.resolve(subDir).findTillRoot(".gpg-id", repoRoot)
+ Paths.get(repoRoot.absolutePathString(), subDir).findTillRoot(".gpg-id", repoRoot)
?: repoRoot.resolve(".gpg-id").createFile()
val gpgIdentifiers =
gpgIdentifierFile