| @@ -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])); | |||||
| } | } | ||||
| } | } | ||||
| @@ -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 { | ||||
| @@ -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 { | ||||