You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by bu...@apache.org on 2005/12/05 19:06:41 UTC

DO NOT REPLY [Bug 37795] New: - [PATCH] Making file sizes optional in DifferentSelector

DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=37795>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=37795

           Summary: [PATCH] Making file sizes optional in DifferentSelector
           Product: Ant
           Version: 1.6.5
          Platform: All
        OS/Version: All
            Status: NEW
          Keywords: PatchAvailable
          Severity: enhancement
          Priority: P2
         Component: Core tasks
        AssignedTo: dev@ant.apache.org
        ReportedBy: geborg@gmail.com


Hello,

the Selector org.apache.tools.ant.types.selectors.DifferentSelector compares to
directory trees by file times (last change), file sizes (number of bytes), file
contents (byte compare) and of course existenz. Only file times and file
contents were optional so far via the attributes ignorefiletimes="true/false"
and ignorecontents="true/false". I added the attribute
ignorefilesizes="true/false" to make the file size criteria optional. Setting
all attributes equal "true" you can now only compare by existenz, which in my
case was very usefull to synchronize a folder under source control with a
temporary folder containing build outputs.

below the output of 

diff -u DifferentSelector.java.orig DifferentSelector.java > DifferentSelector.diffs

for my patch.

greetz,
Georg Boecherer

BEGIN DifferentSelector.diffs

--- DifferentSelector.java.orig	2005-12-05 19:48:58.000000000 +0100
+++ DifferentSelector.java	2005-12-05 19:48:39.000000000 +0100
@@ -50,10 +50,17 @@
 
     private FileUtils fileUtils = FileUtils.newFileUtils();
 
+	private boolean ignoreFileSizes = false;
     private boolean ignoreFileTimes = true;
     private boolean ignoreContents = false;
 
-
+	/**
+     * This flag tells the selector to ignore file sizes in the comparison
+     * @param ignoreFileSizes if true ignore file sizes
+     */
+    public void setIgnoreFileSizes(boolean ignoreFileSizes) {
+        this.ignoreFileSizes = ignoreFileSizes;
+    }
     /**
      * This flag tells the selector to ignore file times in the comparison
      * @param ignoreFileTimes if true ignore file times
@@ -82,11 +89,13 @@
             return true;
         }
 
-        if (srcfile.length() != destfile.length()) {
-            // different size =>different files
-            return true;
+		if (!ignoreFileSizes) {
+	        if (srcfile.length() != destfile.length()) {
+	            // different size => different files
+	            return true;
+			}
         }
-
+        
         if (!ignoreFileTimes) {
             //same date if dest timestamp is within granularity of the srcfile
             boolean sameDate;
@@ -110,5 +119,4 @@
             return false;
         }
     }
-}
-
+}
\ No newline at end of file

END DifferentSelector.diffs

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org