commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r765188 - /commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/changes/ChangeSetPerformer.java
Date Wed, 15 Apr 2009 13:33:49 GMT
Author: sebb
Date: Wed Apr 15 13:33:48 2009
New Revision: 765188

URL: http://svn.apache.org/viewvc?rev=765188&view=rev
Log:
Fix bug: deleteDir should not delete file with matching name
Don't exit loop if name does not match
Use startsWith() rather than match() as it's simpler and quicker

Modified:
    commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/changes/ChangeSetPerformer.java

Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/changes/ChangeSetPerformer.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/changes/ChangeSetPerformer.java?rev=765188&r1=765187&r2=765188&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/changes/ChangeSetPerformer.java
(original)
+++ commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/changes/ChangeSetPerformer.java
Wed Apr 15 13:33:48 2009
@@ -89,8 +89,7 @@
                         break;
                     }
                 } else if(type == Change.TYPE_DELETE_DIR && name != null) {
-                    if (name.matches(
-                            change.targetFile() + "/.*")) {
+                    if (name.startsWith(change.targetFile() + "/")) {
                         copy = false;
                         break;
                     }
@@ -121,14 +120,13 @@
             for (Iterator it = workingSet.iterator(); it.hasNext();) {
                 Change change = (Change) it.next();
                 final int type = change.type();
-                if (type == Change.TYPE_DELETE || type == Change.TYPE_DELETE_DIR) {
-                    String target = change.targetFile();
-
-                    if (source.equals(target)) {
-                        return true;
-                    }
+                String target = change.targetFile();
+                if (type == Change.TYPE_DELETE && source.equals(target)) {
+                    return true;
+                }
 
-                    return (type == Change.TYPE_DELETE_DIR) && source.matches(target
+ "/.*");
+                if (type == Change.TYPE_DELETE_DIR && source.startsWith(target +
"/")){
+                    return true;
                 }
             }
         }



Mime
View raw message