You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by bo...@apache.org on 2015/05/06 06:32:49 UTC
svn commit: r1677921 - in /commons/proper/compress/trunk/src:
changes/changes.xml
main/java/org/apache/commons/compress/archivers/tar/TarArchiveEntry.java
main/java/org/apache/commons/compress/archivers/tar/TarArchiveOutputStream.java
Author: bodewig
Date: Wed May 6 04:32:48 2015
New Revision: 1677921
URL: http://svn.apache.org/r1677921
Log:
COMPRESS-315 allow tar entries with gid/uid > Integer.MAX_INT
Modified:
commons/proper/compress/trunk/src/changes/changes.xml
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveEntry.java
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveOutputStream.java
Modified: commons/proper/compress/trunk/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/changes/changes.xml?rev=1677921&r1=1677920&r2=1677921&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/changes/changes.xml (original)
+++ commons/proper/compress/trunk/src/changes/changes.xml Wed May 6 04:32:48 2015
@@ -54,6 +54,10 @@ breaks backwards compatibility for code
This also changes the superclass of ZCompressorInputStream.
">
+ <action issue="COMPRESS-315" type="add" date="2015-05-06">
+ TarArchiveOutputStream can now write entries with group or
+ user ids > 0x80000000.
+ </action>
<action issue="COMPRESS-313" type="add" date="2015-03-30">
CompressorStreamFactory can now auto-detect LZMA streams.
</action>
Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveEntry.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveEntry.java?rev=1677921&r1=1677920&r2=1677921&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveEntry.java (original)
+++ commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveEntry.java Wed May 6 04:32:48 2015
@@ -121,10 +121,10 @@ public class TarArchiveEntry implements
private int mode;
/** The entry's user id. */
- private int userId = 0;
+ private long userId = 0;
/** The entry's group id. */
- private int groupId = 0;
+ private long groupId = 0;
/** The entry's size. */
private long size = 0;
@@ -424,9 +424,12 @@ public class TarArchiveEntry implements
* Get this entry's user id.
*
* @return This entry's user id.
+ * @deprecated use #getLongUserId instead as user ids can be
+ * bigger than {@link Integer.MAX_INT}
*/
+ @Deprecated
public int getUserId() {
- return userId;
+ return (int) (userId & 0xffffffff);
}
/**
@@ -435,6 +438,26 @@ public class TarArchiveEntry implements
* @param userId This entry's new user id.
*/
public void setUserId(int userId) {
+ setUserId((long) userId);
+ }
+
+ /**
+ * Get this entry's user id.
+ *
+ * @return This entry's user id.
+ * @since 1.10
+ */
+ public long getLongUserId() {
+ return userId;
+ }
+
+ /**
+ * Set this entry's user id.
+ *
+ * @param userId This entry's new user id.
+ * @since 1.10
+ */
+ public void setUserId(long userId) {
this.userId = userId;
}
@@ -442,9 +465,12 @@ public class TarArchiveEntry implements
* Get this entry's group id.
*
* @return This entry's group id.
+ * @deprecated use #getLongGroupId instead as group ids can be
+ * bigger than {@link Integer.MAX_INT}
*/
+ @Deprecated
public int getGroupId() {
- return groupId;
+ return (int) (groupId & 0xffffffff);
}
/**
@@ -453,6 +479,24 @@ public class TarArchiveEntry implements
* @param groupId This entry's new group id.
*/
public void setGroupId(int groupId) {
+ setGroupId((long) groupId);
+ }
+
+ /**
+ * Get this entry's group id.
+ *
+ * @return This entry's group id.
+ */
+ public long getLongGroupId() {
+ return groupId;
+ }
+
+ /**
+ * Set this entry's group id.
+ *
+ * @param groupId This entry's new group id.
+ */
+ public void setGroupId(long groupId) {
this.groupId = groupId;
}
Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveOutputStream.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveOutputStream.java?rev=1677921&r1=1677920&r2=1677921&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveOutputStream.java (original)
+++ commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveOutputStream.java Wed May 6 04:32:48 2015
@@ -584,12 +584,12 @@ public class TarArchiveOutputStream exte
TarArchiveEntry entry) {
addPaxHeaderForBigNumber(paxHeaders, "size", entry.getSize(),
TarConstants.MAXSIZE);
- addPaxHeaderForBigNumber(paxHeaders, "gid", entry.getGroupId(),
+ addPaxHeaderForBigNumber(paxHeaders, "gid", entry.getLongGroupId(),
TarConstants.MAXID);
addPaxHeaderForBigNumber(paxHeaders, "mtime",
entry.getModTime().getTime() / 1000,
TarConstants.MAXSIZE);
- addPaxHeaderForBigNumber(paxHeaders, "uid", entry.getUserId(),
+ addPaxHeaderForBigNumber(paxHeaders, "uid", entry.getLongUserId(),
TarConstants.MAXID);
// star extensions by J\u00f6rg Schilling
addPaxHeaderForBigNumber(paxHeaders, "SCHILY.devmajor",
@@ -610,11 +610,11 @@ public class TarArchiveOutputStream exte
private void failForBigNumbers(TarArchiveEntry entry) {
failForBigNumber("entry size", entry.getSize(), TarConstants.MAXSIZE);
- failForBigNumberWithPosixMessage("group id", entry.getGroupId(), TarConstants.MAXID);
+ failForBigNumberWithPosixMessage("group id", entry.getLongGroupId(), TarConstants.MAXID);
failForBigNumber("last modification time",
entry.getModTime().getTime() / 1000,
TarConstants.MAXSIZE);
- failForBigNumber("user id", entry.getUserId(), TarConstants.MAXID);
+ failForBigNumber("user id", entry.getLongUserId(), TarConstants.MAXID);
failForBigNumber("mode", entry.getMode(), TarConstants.MAXID);
failForBigNumber("major device number", entry.getDevMajor(),
TarConstants.MAXID);