Browse Source

configurable number of retries in get, option to skip existing files. Submitted by David M. Lloyd. PR 40058

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@797509 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 16 years ago
parent
commit
5c6ae59fcc
5 changed files with 54 additions and 2 deletions
  1. +1
    -0
      CONTRIBUTORS
  2. +4
    -0
      WHATSNEW
  3. +5
    -0
      contributors.xml
  4. +12
    -0
      docs/manual/CoreTasks/get.html
  5. +32
    -2
      src/main/org/apache/tools/ant/taskdefs/Get.java

+ 1
- 0
CONTRIBUTORS View File

@@ -72,6 +72,7 @@ David Gärtner
David S. Johnson
David Kavanagh
David LeRoy
David M. Lloyd
David Maclean
David Rees
Denis Hennessy


+ 4
- 0
WHATSNEW View File

@@ -808,6 +808,10 @@ Other changes:
expression based way to determine progress based on logged messages.
Bugzilla Report 39957.

* the number of retries on error in <get> is now configurable. <get>
can be told to not download files that already exist locally.
Bugzilla Report 40058.

Changes from Ant 1.7.0 TO Ant 1.7.1
=============================================



+ 5
- 0
contributors.xml View File

@@ -312,6 +312,11 @@
<first>David</first>
<last>LeRoy</last>
</name>
<name>
<first>David</first>
<middle>M.</middle>
<last>Lloyd</last>
</name>
<name>
<first>David</first>
<last>Maclean</last>


+ 12
- 0
docs/manual/CoreTasks/get.html View File

@@ -103,6 +103,18 @@ plain text' authentication is used. This is only secure over an HTTPS link.
<td align="center" valign="top">No: default 0 which means no
maximum time</td>
</tr>
<tr>
<td valign="top">retries</td>
<td valign="top">the number of retries on error<br/>
<em>since Ant 1.8.0</em></td>
<td align="center" valign="top">No; default "3"</td>
</tr>
<tr>
<td valign="top">skipexisting</td>
<td valign="top">skip files that already exist on the local filesystem<br/>
<em>since Ant 1.8.0</em></td>
<td align="center" valign="top">No; default "false"</td>
</tr>
</table>
<h3>Examples</h3>
<pre> &lt;get src=&quot;http://ant.apache.org/&quot; dest=&quot;help/index.html&quot;/&gt;</pre>


+ 32
- 2
src/main/org/apache/tools/ant/taskdefs/Get.java View File

@@ -65,6 +65,8 @@ public class Get extends Task {
private String uname = null;
private String pword = null;
private long maxTime = 0;
private int numberRetries = NUMBER_RETRIES;
private boolean skipExisting = false;

/**
* Does the work.
@@ -108,6 +110,12 @@ public class Get extends Task {
throws IOException {
checkAttributes();

if (dest.exists() && skipExisting) {
log("Destination already exists (skipping): "
+ dest.getAbsolutePath(), logLevel);
return true;
}

//dont do any progress, unless asked
if (progress == null) {
progress = new NullProgress();
@@ -267,12 +275,34 @@ public class Get extends Task {
* The time in seconds the download is allowed to take before
* being terminated.
*
* @since ant 1.8.0
* @since Ant 1.8.0
*/
public void setMaxTime(long maxTime) {
this.maxTime = maxTime;
}

/**
* The number of retries to attempt upon error, defaults to 3.
*
* @param r retry count
*
* @since Ant 1.8.0
*/
public void setRetries(int r) {
this.numberRetries = r;
}

/**
* Skip files that already exist locally.
*
* @param s "true" to skip existing destination files
*
* @since Ant 1.8.0
*/
public void setSkipExisting(boolean s) {
this.skipExisting = s;
}

/**
* Interface implemented for reporting
* progess of downloading.
@@ -536,7 +566,7 @@ public class Get extends Task {

private boolean downloadFile()
throws FileNotFoundException, IOException {
for (int i = 0; i < NUMBER_RETRIES; i++) {
for (int i = 0; i < numberRetries; i++) {
// this three attempt trick is to get round quirks in different
// Java implementations. Some of them take a few goes to bind
// property; we ignore the first couple of such failures.


Loading…
Cancel
Save