aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java
diff options
context:
space:
mode:
authorHarsh Shandilya <msfjarvis@gmail.com>2020-09-13 15:24:15 +0530
committerGitHub <noreply@github.com>2020-09-13 15:24:15 +0530
commiteef809760c7359a34b414af45165b157813e78af (patch)
treeb314cf6cf04f104abd0275aeef4b125d1d76d1db /app/src/main/java
parentf2647dfbe61d5ee557d68ec1ed6676783bb8c9f2 (diff)
PasswordRepository: properly gate symlink feature (#1098)
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
Diffstat (limited to 'app/src/main/java')
-rw-r--r--app/src/main/java/com/zeapo/pwdstore/utils/PasswordRepository.kt16
1 files changed, 9 insertions, 7 deletions
diff --git a/app/src/main/java/com/zeapo/pwdstore/utils/PasswordRepository.kt b/app/src/main/java/com/zeapo/pwdstore/utils/PasswordRepository.kt
index 443e7398..f1655b3b 100644
--- a/app/src/main/java/com/zeapo/pwdstore/utils/PasswordRepository.kt
+++ b/app/src/main/java/com/zeapo/pwdstore/utils/PasswordRepository.kt
@@ -29,17 +29,15 @@ import org.eclipse.jgit.util.FS_POSIX_Java6
open class PasswordRepository protected constructor() {
+ @RequiresApi(Build.VERSION_CODES.O)
private class FS_POSIX_Java6_with_optional_symlinks : FS_POSIX_Java6() {
override fun supportsSymlinks() = Build.VERSION.SDK_INT >= Build.VERSION_CODES.O
- @RequiresApi(Build.VERSION_CODES.O)
override fun isSymLink(file: File) = Files.isSymbolicLink(file.toPath())
- @RequiresApi(Build.VERSION_CODES.O)
override fun readSymLink(file: File) = Files.readSymbolicLink(file.toPath()).toString()
- @RequiresApi(Build.VERSION_CODES.O)
override fun createSymLink(source: File, target: String) {
val sourcePath = source.toPath()
if (Files.exists(sourcePath, LinkOption.NOFOLLOW_LINKS))
@@ -48,6 +46,7 @@ open class PasswordRepository protected constructor() {
}
}
+ @RequiresApi(Build.VERSION_CODES.O)
private class Java7FSFactory : FS.FSFactory() {
override fun detect(cygwinUsed: Boolean?): FS {
@@ -109,10 +108,13 @@ open class PasswordRepository protected constructor() {
if (repository == null && localDir != null) {
val builder = FileRepositoryBuilder()
repository = runCatching {
- builder.setGitDir(localDir)
- .setFS(Java7FSFactory().detect(null))
- .readEnvironment()
- .build()
+ builder.run {
+ gitDir = localDir
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
+ fs = Java7FSFactory().detect(null)
+ }
+ readEnvironment()
+ }.build()
}.getOrElse { e ->
e.printStackTrace()
null