Skip to content

Commit 2e0fe42

Browse files
authored
#50 - timeout configuration (#51)
1 parent 9f47027 commit 2e0fe42

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed

src/main/scala/ray/fs2/ftp/Ftp.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,9 @@ object Ftp {
8383
ftpClient.setFileType(FTP.BINARY_FILE_TYPE)
8484
}
8585

86+
ftpClient.setConnectTimeout(settings.connectTimeOut)
87+
ftpClient.setDefaultTimeout(settings.timeOut)
88+
8689
if (settings.passiveMode) {
8790
ftpClient.enterLocalPassiveMode()
8891
}

src/main/scala/ray/fs2/ftp/FtpSettings.scala

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ object FtpSettings {
5050
sftpIdentity: Option[SftpIdentity],
5151
strictHostKeyChecking: Boolean,
5252
knownHosts: Option[String],
53+
timeOut: Int,
54+
connectTimeOut: Int,
5355
sshConfig: SshConfig
5456
) extends FtpSettings[JSFTPClient]
5557

@@ -63,6 +65,8 @@ object FtpSettings {
6365
sftpIdentity = None,
6466
strictHostKeyChecking = false,
6567
knownHosts = None,
68+
0,
69+
0,
6670
new DefaultSshConfig()
6771
)
6872

@@ -74,6 +78,8 @@ object FtpSettings {
7478
sftpIdentity = Some(identity),
7579
strictHostKeyChecking = false,
7680
knownHosts = None,
81+
0,
82+
0,
7783
new DefaultSshConfig()
7884
)
7985
}
@@ -85,16 +91,18 @@ object FtpSettings {
8591
binary: Boolean,
8692
passiveMode: Boolean,
8793
proxy: Option[Proxy],
88-
secure: Boolean
94+
secure: Boolean,
95+
timeOut: Int,
96+
connectTimeOut: Int
8997
) extends FtpSettings[JFTPClient]
9098

9199
object UnsecureFtpSettings {
92100

93101
def apply(host: String, port: Int, creds: FtpCredentials): UnsecureFtpSettings =
94-
new UnsecureFtpSettings(host, port, creds, true, true, None, false)
102+
new UnsecureFtpSettings(host, port, creds, true, true, None, false, 0, 0)
95103

96104
def secure(host: String, port: Int, creds: FtpCredentials): UnsecureFtpSettings =
97-
new UnsecureFtpSettings(host, port, creds, true, true, None, true)
105+
new UnsecureFtpSettings(host, port, creds, true, true, None, true, 0, 0)
98106
}
99107

100108
}

src/main/scala/ray/fs2/ftp/SFtp.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,9 @@ object SFtp {
104104
else
105105
knownHosts.map(new File(_)).foreach(ssh.loadKnownHosts)
106106

107+
ssh.setTimeout(settings.timeOut)
108+
ssh.setConnectTimeout(settings.connectTimeOut)
109+
107110
ssh.connect(host, port)
108111

109112
sftpIdentity

0 commit comments

Comments
 (0)