Merge branch 'security-rc' into SECURITY-144-rc

Conflicts:
	core/src/main/java/hudson/FilePath.java
This commit is contained in:
Jesse Glick committed 2014-10-26 13:55:39 -07:00
commit f0658e233d
33 files changed
+461 -99

No files matched your search

+72
View File
@@ -89,6 +89,7 @@ import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.RandomAccessFile;
import java.io.Serializable;
import java.io.Writer;
import java.lang.reflect.Field;
@@ -1760,6 +1761,77 @@ public final class FilePath implements Serializable {
return p.getIn();
}
/**
* Reads this file from the specific offset.
*/
public InputStream readFromOffset(final long offset) throws IOException {
if(channel ==null) {
final RandomAccessFile raf = new RandomAccessFile(new File(remote), "r");
try {
raf.seek(offset);
} catch (IOException e) {
try {
raf.close();
} catch (IOException e1) {
// ignore
}
throw e;
}
return new InputStream() {
@Override
public int read() throws IOException {
return raf.read();
}
@Override
public void close() throws IOException {
raf.close();
}
@Override
public int read(byte[] b, int off, int len) throws IOException {
return raf.read(b, off, len);
}
@Override
public int read(byte[] b) throws IOException {
return raf.read(b);
}
};
}
final Pipe p = Pipe.createRemoteToLocal();
channel.callAsync(new Callable<Void, IOException>() {
private static final long serialVersionUID = 1L;
public Void call() throws IOException {
final OutputStream out = new java.util.zip.GZIPOutputStream(p.getOut(), 8192);
RandomAccessFile raf = null;
try {
raf = new RandomAccessFile(new File(remote), "r");
raf.seek(offset);
byte[] buf = new byte[8192];
int len;
while ((len = raf.read(buf)) >= 0) {
out.write(buf, 0, len);
}
return null;
} finally {
IOUtils.closeQuietly(out);
if (raf != null) {
try {
raf.close();
} catch (IOException e) {
// ignore
}
}
}
}
});
return new java.util.zip.GZIPInputStream(p.getIn());
}
/**
* Reads this file into a string, by using the current system encoding.
*/