Browse Source

Revert changes to reverse loops

master
Gintas Grigelionis 7 years ago
parent
commit
ee9a3e5de7
3 changed files with 8 additions and 10 deletions
  1. +4
    -6
      src/main/org/apache/tools/ant/taskdefs/Sync.java
  2. +2
    -2
      src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java
  3. +2
    -2
      src/main/org/apache/tools/ant/taskdefs/optional/net/FTPTaskMirrorImpl.java

+ 4
- 6
src/main/org/apache/tools/ant/taskdefs/Sync.java View File

@@ -240,9 +240,8 @@ public class Sync extends Task {
// leaves before their parent nodes - thus making sure (well, // leaves before their parent nodes - thus making sure (well,
// more likely) that the directories are empty when we try to // more likely) that the directories are empty when we try to
// delete them. // delete them.
Arrays.sort(dirs, Comparator.reverseOrder());
for (String dir : dirs) {
File f = new File(toDir, dir);
for (int i = dirs.length - 1; i >= 0; --i) {
File f = new File(toDir, dirs[i]);
String[] children = f.list(); String[] children = f.list();
if (children == null || children.length < 1) { if (children == null || children.length < 1) {
log("Removing orphan directory: " + f, Project.MSG_DEBUG); log("Removing orphan directory: " + f, Project.MSG_DEBUG);
@@ -257,9 +256,8 @@ public class Sync extends Task {
fs.setDir(toDir); fs.setDir(toDir);
String[] preservedDirs = String[] preservedDirs =
fs.getDirectoryScanner(getProject()).getIncludedDirectories(); fs.getDirectoryScanner(getProject()).getIncludedDirectories();
Arrays.sort(preservedDirs, Comparator.reverseOrder());
for (String dir : preservedDirs) {
preservedDirectories.add(new File(toDir, dir));
for (int i = preservedDirs.length - 1; i >= 0; --i) {
preservedDirectories.add(new File(toDir, preservedDirs[i]));
} }
} }




+ 2
- 2
src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java View File

@@ -1808,8 +1808,8 @@ public class FTP extends Task implements FTPTaskConfig {
if (action == RM_DIR) { if (action == RM_DIR) {
// to remove directories, start by the end of the list // to remove directories, start by the end of the list
// the trunk does not let itself be removed before the leaves // the trunk does not let itself be removed before the leaves
Arrays.sort(dsfiles, Comparator.reverseOrder());
for (final String dsfile : dsfiles) {
for (int i = dsfiles.length - 1; i >= 0; i--) {
final String dsfile = dsfiles[i];
executeRetryable(h, () -> rmDir(ftp, dsfile), dsfile); executeRetryable(h, () -> rmDir(ftp, dsfile), dsfile);
} }
} else { } else {


+ 2
- 2
src/main/org/apache/tools/ant/taskdefs/optional/net/FTPTaskMirrorImpl.java View File

@@ -1186,8 +1186,8 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror {
if (task.getAction() == FTPTask.RM_DIR) { if (task.getAction() == FTPTask.RM_DIR) {
// to remove directories, start by the end of the list // to remove directories, start by the end of the list
// the trunk does not let itself be removed before the leaves // the trunk does not let itself be removed before the leaves
Arrays.sort(dsfiles, Comparator.reverseOrder());
for (final String dsfile : dsfiles) {
for (int i = dsfiles.length - 1; i >= 0; i--) {
final String dsfile = dsfiles[i];
executeRetryable(h, () -> rmDir(ftp, dsfile), dsfile); executeRetryable(h, () -> rmDir(ftp, dsfile), dsfile);
} }
} else { } else {


Loading…
Cancel
Save