ASF Bugzilla – Attachment 36481 Details for
Bug 63252
[PATCH] FTP prevent No Transfer Timeout during long listings
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
patch
patch.txt (text/plain), 2.86 KB, created by
Eugène Adell
on 2019-03-10 09:04:42 UTC
(
hide
)
Description:
patch
Filename:
MIME Type:
Creator:
Eugène Adell
Created:
2019-03-10 09:04:42 UTC
Size:
2.86 KB
patch
obsolete
>diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java b/src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java >index aa69cf7..7120f7d 100644 >--- a/src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java >+++ b/src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java >@@ -143,6 +143,8 @@ public class FTP extends Task implements FTPTaskConfig { > private String siteCommand = null; > private String initialSiteCommand = null; > private boolean enableRemoteVerification = true; >+ private int wakeUpTransferInterval = -1; >+ private long lastWakeUpTime = 0; > > protected static final String[] ACTION_STRS = { //NOSONAR > "sending", >@@ -546,6 +548,14 @@ public class FTP extends Task implements FTPTaskConfig { > } > } > } >+ if(wakeUpTransferInterval > 0) { >+ if(wakeUpTransferIntervalExpired()) { >+ getProject().log("wakeUpTransferInterval is reached, trigger a data connection " , Project.MSG_DEBUG); >+ // send a minimalist command to trigger a data connection >+ ftp.listFiles(file.getName()); >+ } >+ } >+ > } > ftp.changeToParentDirectory(); > } catch (IOException e) { >@@ -1683,6 +1693,21 @@ public class FTP extends Task implements FTPTaskConfig { > } > > /** >+ * Sets the time interval when we should automatically >+ * call a command triggering a transfer >+ * The parameter is in seconds >+ * >+ * @param wakeUpTransferInterval int >+ * @since Ant 1.10.6 >+ */ >+ public void setWakeUpTransferInterval(int wakeUpTransferInterval) { >+ if(wakeUpTransferInterval > 0) { >+ this.wakeUpTransferInterval = wakeUpTransferInterval; >+ } >+ } >+ >+ >+ /** > * Checks to see that all required parameters are set. > * > * @throws BuildException if the configuration is not valid. >@@ -2410,6 +2435,28 @@ public class FTP extends Task implements FTPTaskConfig { > } > > /** >+ * checks if the wake up interval is expired >+ */ >+ private boolean wakeUpTransferIntervalExpired() { >+ boolean result = false; >+ >+ // on the first call, initialize the keep-alive mechanism >+ // by storing the current date >+ if(lastWakeUpTime == 0) { >+ lastWakeUpTime = (new Date()).getTime(); >+ } >+ else { >+ long currentTime = (new Date()).getTime(); >+ if(currentTime > (lastWakeUpTime + wakeUpTransferInterval*1000)) { >+ lastWakeUpTime = currentTime; >+ result = true; >+ } >+ } >+ >+ return result; >+ } >+ >+ /** > * Runs the task. > * > * @throws BuildException if the task fails or is not configured
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 63252
: 36481