mirror of
https://github.com/jenkinsci/jenkins.git
synced 2026-11-04 23:55:52 +00:00
Merge pull request #1667 from oleg-nenashev/JENKINS-10629-FIX
[JENKINS-28013,JENKINS-28012] - Revert changes for JENKINS-10629
This commit is contained in:
commit
ca21c65bf2
5 files changed
+55
-34
No files matched your search
@@ -33,6 +33,7 @@ import hudson.model.AbstractProject;
|
||||
import hudson.model.Computer;
|
||||
import hudson.model.Item;
|
||||
import hudson.model.TaskListener;
|
||||
import hudson.org.apache.tools.tar.TarInputStream;
|
||||
import hudson.os.PosixAPI;
|
||||
import hudson.os.PosixException;
|
||||
import hudson.remoting.Callable;
|
||||
@@ -69,6 +70,7 @@ import org.apache.commons.io.input.CountingInputStream;
|
||||
import org.apache.tools.ant.DirectoryScanner;
|
||||
import org.apache.tools.ant.Project;
|
||||
import org.apache.tools.ant.types.FileSet;
|
||||
import org.apache.tools.tar.TarEntry;
|
||||
import org.apache.tools.zip.ZipEntry;
|
||||
import org.apache.tools.zip.ZipFile;
|
||||
import org.kohsuke.stapler.Stapler;
|
||||
@@ -118,8 +120,6 @@ import static hudson.Util.*;
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import jenkins.security.MasterToSlaveCallable;
|
||||
import org.apache.commons.compress.archivers.tar.TarArchiveEntry;
|
||||
import org.apache.commons.compress.archivers.tar.TarArchiveInputStream;
|
||||
import org.jenkinsci.remoting.RoleChecker;
|
||||
import org.jenkinsci.remoting.RoleSensitive;
|
||||
|
||||
@@ -2268,15 +2268,12 @@ public final class FilePath implements Serializable {
|
||||
|
||||
/**
|
||||
* Reads from a tar stream and stores obtained files to the base dir.
|
||||
* @since TODO supports large files > 10 GB, migration to commons-compress
|
||||
*/
|
||||
private void readFromTar(String name, File baseDir, InputStream in) throws IOException {
|
||||
TarArchiveInputStream t = new TarArchiveInputStream(in);
|
||||
|
||||
// TarInputStream t = new TarInputStream(in);
|
||||
TarInputStream t = new TarInputStream(in);
|
||||
try {
|
||||
TarArchiveEntry te;
|
||||
while ((te = t.getNextTarEntry()) != null) {
|
||||
TarEntry te;
|
||||
while ((te = t.getNextEntry()) != null) {
|
||||
File f = new File(baseDir,te.getName());
|
||||
if(te.isDirectory()) {
|
||||
mkdirs(f);
|
||||
@@ -2285,7 +2282,8 @@ public final class FilePath implements Serializable {
|
||||
if (parent != null) mkdirs(parent);
|
||||
writing(f);
|
||||
|
||||
if (te.isSymbolicLink()) {
|
||||
byte linkFlag = (Byte) LINKFLAG_FIELD.get(te);
|
||||
if (linkFlag==TarEntry.LF_SYMLINK) {
|
||||
new FilePath(f).symlinkTo(te.getLinkName(), TaskListener.NULL);
|
||||
} else {
|
||||
IOUtils.copy(t,f);
|
||||
@@ -2302,6 +2300,8 @@ public final class FilePath implements Serializable {
|
||||
} catch (InterruptedException e) {
|
||||
Thread.currentThread().interrupt(); // process this later
|
||||
throw new IOException("Failed to extract "+name,e);
|
||||
} catch (IllegalAccessException e) {
|
||||
throw new IOException("Failed to extract "+name,e);
|
||||
} finally {
|
||||
t.close();
|
||||
}
|
||||
@@ -2725,6 +2725,20 @@ public final class FilePath implements Serializable {
|
||||
}
|
||||
};
|
||||
|
||||
private static final Field LINKFLAG_FIELD = getTarEntryLinkFlagField();
|
||||
|
||||
private static Field getTarEntryLinkFlagField() {
|
||||
try {
|
||||
Field f = TarEntry.class.getDeclaredField("linkFlag");
|
||||
f.setAccessible(true);
|
||||
return f;
|
||||
} catch (SecurityException e) {
|
||||
throw new AssertionError(e);
|
||||
} catch (NoSuchFieldException e) {
|
||||
throw new AssertionError(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the {@link FilePath} representation of the "~" directory
|
||||
* (User's home directory in the Unix sense) of the given channel.
|
||||
|
||||
Reference in new issue
Block a user