Skip to content
This repository was archived by the owner on Oct 15, 2024. It is now read-only.

Commit eef8097

Browse files
authored
PasswordRepository: properly gate symlink feature (#1098)
Signed-off-by: Harsh Shandilya <[email protected]>
1 parent f2647df commit eef8097

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

app/src/main/java/com/zeapo/pwdstore/utils/PasswordRepository.kt

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,15 @@ import org.eclipse.jgit.util.FS_POSIX_Java6
2929

3030
open class PasswordRepository protected constructor() {
3131

32+
@RequiresApi(Build.VERSION_CODES.O)
3233
private class FS_POSIX_Java6_with_optional_symlinks : FS_POSIX_Java6() {
3334

3435
override fun supportsSymlinks() = Build.VERSION.SDK_INT >= Build.VERSION_CODES.O
3536

36-
@RequiresApi(Build.VERSION_CODES.O)
3737
override fun isSymLink(file: File) = Files.isSymbolicLink(file.toPath())
3838

39-
@RequiresApi(Build.VERSION_CODES.O)
4039
override fun readSymLink(file: File) = Files.readSymbolicLink(file.toPath()).toString()
4140

42-
@RequiresApi(Build.VERSION_CODES.O)
4341
override fun createSymLink(source: File, target: String) {
4442
val sourcePath = source.toPath()
4543
if (Files.exists(sourcePath, LinkOption.NOFOLLOW_LINKS))
@@ -48,6 +46,7 @@ open class PasswordRepository protected constructor() {
4846
}
4947
}
5048

49+
@RequiresApi(Build.VERSION_CODES.O)
5150
private class Java7FSFactory : FS.FSFactory() {
5251

5352
override fun detect(cygwinUsed: Boolean?): FS {
@@ -109,10 +108,13 @@ open class PasswordRepository protected constructor() {
109108
if (repository == null && localDir != null) {
110109
val builder = FileRepositoryBuilder()
111110
repository = runCatching {
112-
builder.setGitDir(localDir)
113-
.setFS(Java7FSFactory().detect(null))
114-
.readEnvironment()
115-
.build()
111+
builder.run {
112+
gitDir = localDir
113+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
114+
fs = Java7FSFactory().detect(null)
115+
}
116+
readEnvironment()
117+
}.build()
116118
}.getOrElse { e ->
117119
e.printStackTrace()
118120
null

0 commit comments

Comments
 (0)