From 77e77be999ed45dfccf1c3db838821442931eff4 Mon Sep 17 00:00:00 2001 From: Harsh Shandilya Date: Thu, 3 Dec 2020 16:52:22 +0530 Subject: Set 10 second timeout on JGit transport commands (#1230) * GitOperation: set a 10 second connection timeout Signed-off-by: Harsh Shandilya * Update changelog Signed-off-by: Harsh Shandilya --- .../main/java/com/zeapo/pwdstore/git/operation/GitOperation.kt | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'app/src/main') diff --git a/app/src/main/java/com/zeapo/pwdstore/git/operation/GitOperation.kt b/app/src/main/java/com/zeapo/pwdstore/git/operation/GitOperation.kt index 491feaf0..5649e8de 100644 --- a/app/src/main/java/com/zeapo/pwdstore/git/operation/GitOperation.kt +++ b/app/src/main/java/com/zeapo/pwdstore/git/operation/GitOperation.kt @@ -108,6 +108,7 @@ abstract class GitOperation(protected val callingActivity: FragmentActivity) { (transport as? SshTransport)?.sshSessionFactory = sshSessionFactory credentialsProvider?.let { transport.credentialsProvider = it } } + command.setTimeout(CONNECT_TIMEOUT) } } @@ -204,4 +205,12 @@ abstract class GitOperation(protected val callingActivity: FragmentActivity) { sshSessionFactory?.close() } } + + companion object { + + /** + * Timeout in seconds before [TransportCommand] will abort a stalled IO operation. + */ + private const val CONNECT_TIMEOUT = 10 + } } -- cgit v1.2.3