| @@ -146,6 +146,9 @@ public class FTP extends Task implements FTPTaskConfig { | |||||
| private String initialSiteCommand = null; | private String initialSiteCommand = null; | ||||
| private boolean enableRemoteVerification = true; | private boolean enableRemoteVerification = true; | ||||
| private int dataTimeout = -1; | private int dataTimeout = -1; | ||||
| private int wakeUpTransferInterval = -1; | |||||
| private long lastWakeUpTime = 0; | |||||
| protected static final String[] ACTION_STRS = { //NOSONAR | protected static final String[] ACTION_STRS = { //NOSONAR | ||||
| "sending", | "sending", | ||||
| @@ -547,6 +550,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(); | ftp.changeToParentDirectory(); | ||||
| } catch (FTPConnectionClosedException ftpcce) { | } catch (FTPConnectionClosedException ftpcce) { | ||||
| @@ -1710,6 +1721,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. | * Checks to see that all required parameters are set. | ||||
| * | * | ||||
| @@ -2437,6 +2463,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. | * Runs the task. | ||||
| * | * | ||||