ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject svn commit: r727977 - /ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Sync.java
Date Fri, 19 Dec 2008 08:37:13 GMT
Author: bodewig
Date: Fri Dec 19 00:37:12 2008
New Revision: 727977

URL: http://svn.apache.org/viewvc?rev=727977&view=rev
Log:
Avoid slow scan unless it really is required

Modified:
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Sync.java

Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Sync.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Sync.java?rev=727977&r1=727976&r2=727977&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Sync.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Sync.java Fri Dec 19 00:37:12 2008
@@ -128,18 +128,12 @@
 
         // Get rid of empty directories on the destination side
         if (!myCopy.getIncludeEmptyDirs()
-            || (syncTarget != null
-                && syncTarget.getPreserveEmptyDirs() == Boolean.FALSE)) {
+            || getExplicitPreserveEmptyDirs() == Boolean.FALSE) {
             log("PASS#3: Removing empty directories from " + toDir,
                 Project.MSG_DEBUG);
 
             int removedDirCount = 0;
             if (!myCopy.getIncludeEmptyDirs()) {
-                if (syncTarget != null
-                    && syncTarget.getPreserveEmptyDirs() != Boolean.TRUE) {
-                    preservedDirectories.clear();
-                }
-
                 removedDirCount =
                     removeEmptyDirectories(toDir, false, preservedDirectories);
             } else { // must be syncTarget.preserveEmptydirs == FALSE
@@ -179,8 +173,8 @@
      * @param  file the initial file or directory to scan or test.
      * @param  preservedDirectories will be filled with the directories
      *         matched by preserveInTarget - if any.  Will not be
-     *         filled unless either preserveEmptyDirs is set or
-     *         includeEmptyDirs is true.
+     *         filled unless preserveEmptyDirs and includeEmptyDirs
+     *         conflict.
      * @return the number of orphaned files and directories actually removed.
      * Position 0 of the array is the number of orphaned directories.
      * Position 1 of the array is the number or orphaned files.
@@ -249,13 +243,11 @@
             }
         }
 
-        if (syncTarget != null) {
-            if (syncTarget.getPreserveEmptyDirs() != null
-                || myCopy.getIncludeEmptyDirs()) {
-                String[] preservedDirs = ds.getExcludedDirectories();
-                for (int i = preservedDirs.length - 1; i >= 0; --i) {
-                    preservedDirectories.add(new File(toDir, preservedDirs[i]));
-                }
+        Boolean ped = getExplicitPreserveEmptyDirs();
+        if (ped != null && ped.booleanValue() != myCopy.getIncludeEmptyDirs()) {
+            String[] preservedDirs = ds.getExcludedDirectories();
+            for (int i = preservedDirs.length - 1; i >= 0; --i) {
+                preservedDirectories.add(new File(toDir, preservedDirs[i]));
             }
         }
 
@@ -428,6 +420,16 @@
     }
 
     /**
+     * The value of preserveTarget's preserveEmptyDirs attribute if
+     * specified and preserveTarget has been used in the first place.
+     *
+     * @since Ant 1.8.0.
+     */
+    private Boolean getExplicitPreserveEmptyDirs() {
+        return syncTarget == null ? null : syncTarget.getPreserveEmptyDirs();
+    }
+
+    /**
      * Subclass Copy in order to access it's file/dir maps.
      */
     public static class MyCopy extends Copy {



Mime
View raw message