|
17 | 17 | * limitations under the License.
|
18 | 18 | */
|
19 | 19 |
|
20 |
| -import java.io.BufferedOutputStream; |
21 |
| -import java.io.File; |
22 |
| -import java.io.FileOutputStream; |
23 |
| -import java.io.IOException; |
24 |
| -import java.io.InputStream; |
25 |
| -import java.io.OutputStream; |
26 |
| -import java.util.zip.GZIPOutputStream; |
27 |
| - |
28 | 20 | import org.apache.commons.compress.compressors.bzip2.BZip2CompressorOutputStream;
|
29 | 21 | import org.codehaus.plexus.archiver.AbstractArchiver;
|
30 | 22 | import org.codehaus.plexus.archiver.ArchiveEntry;
|
|
38 | 30 | import org.codehaus.plexus.util.IOUtil;
|
39 | 31 | import org.codehaus.plexus.util.StringUtils;
|
40 | 32 |
|
| 33 | +import java.io.BufferedOutputStream; |
| 34 | +import java.io.File; |
| 35 | +import java.io.FileOutputStream; |
| 36 | +import java.io.IOException; |
| 37 | +import java.io.InputStream; |
| 38 | +import java.io.OutputStream; |
| 39 | +import java.util.zip.GZIPOutputStream; |
| 40 | + |
41 | 41 | /**
|
42 | 42 | * @author <a href="mailto:[email protected]">Emmanuel Venisse</a>
|
43 | 43 | * @version $Revision$ $Date$
|
@@ -249,7 +249,7 @@ protected void tarFile( ArchiveEntry entry, TarOutputStream tOut, String vPath )
|
249 | 249 | int pathLength = vPath.length();
|
250 | 250 | try
|
251 | 251 | {
|
252 |
| - TarEntry te = null; |
| 252 | + final TarEntry te; |
253 | 253 | if ( !longFileMode.isGnuMode() && pathLength >= TarConstants.NAMELEN )
|
254 | 254 | {
|
255 | 255 | int maxPosixPathLen = TarConstants.NAMELEN + TarConstants.POSIX_PREFIXLEN;
|
@@ -337,10 +337,20 @@ else if ( longFileMode.isFailMode() )
|
337 | 337 | : options.getUserName() );
|
338 | 338 | te.setGroupName( ( attributes != null && attributes.getGroupName() != null ) ? attributes.getGroupName()
|
339 | 339 | : options.getGroup() );
|
340 |
| - te.setUserId( ( attributes != null && attributes.getUserId() != null) ? attributes.getUserId() |
341 |
| - : options.getUid() ); |
342 |
| - te.setGroupId( ( attributes != null && attributes.getGroupId() != null) ? attributes.getGroupId() |
343 |
| - : options.getGid() ); |
| 340 | + |
| 341 | + final int userId = |
| 342 | + ( attributes != null && attributes.getUserId() != null ) ? attributes.getUserId() : options.getUid(); |
| 343 | + if ( userId > 0 ) |
| 344 | + { |
| 345 | + te.setUserId( userId ); |
| 346 | + } |
| 347 | + |
| 348 | + final int groupId = |
| 349 | + ( attributes != null && attributes.getGroupId() != null ) ? attributes.getGroupId() : options.getGid(); |
| 350 | + if ( groupId > 0 ) |
| 351 | + { |
| 352 | + te.setGroupId( groupId ); |
| 353 | + } |
344 | 354 |
|
345 | 355 | tOut.putNextEntry( te );
|
346 | 356 |
|
|
0 commit comments