fixes COMPRESS-328 TarArchiveEntry preserveLeadingSlashes has no effect on 
setName


Project: http://git-wip-us.apache.org/repos/asf/commons-compress/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-compress/commit/68db5fa9
Tree: http://git-wip-us.apache.org/repos/asf/commons-compress/tree/68db5fa9
Diff: http://git-wip-us.apache.org/repos/asf/commons-compress/diff/68db5fa9

Branch: refs/heads/master
Commit: 68db5fa9ed38fb599c59be98d561daefc541d7da
Parents: ce9e0ce
Author: Torsten Curdt <tcu...@vafer.org>
Authored: Fri Jan 15 15:35:17 2016 +0100
Committer: Torsten Curdt <tcu...@vafer.org>
Committed: Fri Jan 15 15:35:17 2016 +0100

----------------------------------------------------------------------
 RELEASE-NOTES.txt                                           | 9 +++++++++
 .../commons/compress/archivers/tar/TarArchiveEntry.java     | 7 ++++++-
 2 files changed, 15 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-compress/blob/68db5fa9/RELEASE-NOTES.txt
----------------------------------------------------------------------
diff --git a/RELEASE-NOTES.txt b/RELEASE-NOTES.txt
index 03b2ce9..c33ba7f 100644
--- a/RELEASE-NOTES.txt
+++ b/RELEASE-NOTES.txt
@@ -5,6 +5,15 @@ compression and archive formats.  These include: bzip2, gzip, 
pack200,
 lzma, xz, Snappy, traditional Unix Compress, DEFLATE and ar, cpio,
 jar, tar, zip, dump, 7z, arj.
 
+Release 1.11 (not yet released)
+------------
+
+Changes
+o TarArchiveEntry's preserveLeadingSlashes is now a property and used
+  on later calls to setName, too.
+  This behavior is a breaking change.
+  Issue: COMPRESS-328
+
 Release 1.10
 ------------
 

http://git-wip-us.apache.org/repos/asf/commons-compress/blob/68db5fa9/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveEntry.java
----------------------------------------------------------------------
diff --git 
a/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveEntry.java 
b/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveEntry.java
index 341d8bd..8a7af0e 100644
--- 
a/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveEntry.java
+++ 
b/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveEntry.java
@@ -117,6 +117,9 @@ public class TarArchiveEntry implements TarConstants, 
ArchiveEntry {
     /** The entry's name. */
     private String name = "";
 
+    /** Whether to enforce leading slashes on the name */
+    private boolean preserveLeadingSlashes;
+
     /** The entry's permission mode. */
     private int mode;
 
@@ -216,6 +219,8 @@ public class TarArchiveEntry implements TarConstants, 
ArchiveEntry {
     public TarArchiveEntry(String name, boolean preserveLeadingSlashes) {
         this();
 
+        this.preserveLeadingSlashes = preserveLeadingSlashes;
+
         name = normalizeFileName(name, preserveLeadingSlashes);
         boolean isDir = name.endsWith("/");
 
@@ -389,7 +394,7 @@ public class TarArchiveEntry implements TarConstants, 
ArchiveEntry {
      * @param name This entry's new name.
      */
     public void setName(String name) {
-        this.name = normalizeFileName(name, false);
+        this.name = normalizeFileName(name, this.preserveLeadingSlashes);
     }
 
     /**

Reply via email to