Skip to content

Commit

Permalink
Enabled transparent compression support.
Browse files Browse the repository at this point in the history
This only works if the "transparent GZIP support" patch has been
applied against Stapler. Otherwise, this patch will not compile
as the new "LargeText" constructor will not be found.

Additionally, the console.jelly was modified to make use of the
stream instead of the raw file, which is necessary to get the
correct uncompressed size of the file for skipping bytes.

[JENKINS-2551]
[JENKINS-10400]
[JENKINS-13655]

Signed-off-by: Martin Schroeder <martin.h.schroeder@intel.com>
  • Loading branch information
HedAurabesh committed Oct 12, 2012
1 parent 1effef3 commit 346fc99
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 10 deletions.
2 changes: 1 addition & 1 deletion core/src/main/java/hudson/console/AnnotatedLargeText.java
Expand Up @@ -77,7 +77,7 @@ public class AnnotatedLargeText<T> extends LargeText {
private T context;

public AnnotatedLargeText(File file, Charset charset, boolean completed, T context) {
super(file, charset, completed);
super(file, charset, completed, true);
this.context = context;
}

Expand Down
27 changes: 19 additions & 8 deletions core/src/main/java/hudson/model/Run.java
Expand Up @@ -1161,7 +1161,16 @@ public String toString() {
* Returns the log file.
*/
public File getLogFile() {
return new File(getRootDir(),"log");
File rawF = new File(getRootDir(), "log");
if (rawF.isFile()) {
return rawF;
}
File gzF = new File(getRootDir(), "log.gz");
if (gzF.isFile()) {
return gzF;
}
//If both fail, return the standard, uncompressed log file
return rawF;
}

/**
Expand All @@ -1174,13 +1183,15 @@ public File getLogFile() {
*/
public InputStream getLogInputStream() throws IOException {
File logFile = getLogFile();
if (logFile.exists() ) {
return new FileInputStream(logFile);
}

File compressedLogFile = new File(logFile.getParentFile(), logFile.getName()+ ".gz");
if (compressedLogFile.exists()) {
return new GZIPInputStream(new FileInputStream(compressedLogFile));

if (logFile != null && logFile.exists() ) {
// Checking if a ".gz" file was return
FileInputStream fis = new FileInputStream(logFile);
if (logFile.getName().endsWith(".gz")) {
return new GZIPInputStream(fis);
} else {
return fis;
}
}

return new NullInputStream(0);
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/resources/hudson/model/Run/console.jelly
Expand Up @@ -35,7 +35,7 @@ THE SOFTWARE.
</t:buildCaption>
<j:set var="threshold" value="${h.getSystemProperty('hudson.consoleTailKB')?:'150'}" />
<!-- Show at most last 150KB (can override with system property) unless consoleFull is set -->
<j:set var="offset" value="${empty(consoleFull) ? it.logFile.length()-threshold*1024 : 0}" />
<j:set var="offset" value="${empty(consoleFull) ? it.logText.length()-threshold*1024 : 0}" />
<j:choose>
<j:when test="${offset > 0}">
${%skipSome(offset/1024,"consoleFull")}
Expand Down

0 comments on commit 346fc99

Please sign in to comment.