提交 94cbf5ba 编写于 作者: S Stephen Ware 提交者: Kohsuke Kawaguchi

[FIXED JENKINS-7798]

File size should be shown on project dashboard for archived artifacts.

Run.java:
	Add member String length to Artifact object.
	Add paramter String len to Artifact constructor.
	Add method String getLength to Artifact object.
	addArtifacts method of Run class gets length of files as string
	for actual files or "0" if a directory and passes this as arg
	to Artifact constructor.

artifacts-index.jelly and artifactList.jelly
	reworked to use same approach as
	core/src/main/resources/hudson/model/DirectoryBrowserSupport/dir.jelly
	The desire being a consistent look in the interface.
Signed-off-by: NStephen Ware <stephen.e.ware@intel.com>
上级 37a22a1c
......@@ -63,6 +63,9 @@ Upcoming changes</a>
<div id="rc" style="display:none;"><!--=BEGIN=-->
<h3><a name=v1.431>What's new in 1.431</a> <!--=DATE=--></h3>
<ul class=image>
<li class=rfe>
Display the file size in the artifact list page
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-7798">issue 7798</a>)
<li class=rfe>
Fixed a file permission handling in the unzip code.
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-9577">issue 9577</a>)
......
......@@ -878,17 +878,20 @@ public abstract class Run <JobT extends Job<JobT,RunT>,RunT extends Run<JobT,Run
String childPath = path + child;
String childHref = pathHref + Util.rawEncode(child);
File sub = new File(dir, child);
String length = sub.isFile() ? String.valueOf(sub.length()) : "0";
boolean collapsed = (children.length==1 && parent!=null);
Artifact a;
if (collapsed) {
// Collapse single items into parent node where possible:
a = new Artifact(parent.getFileName() + '/' + child, childPath,
sub.isDirectory() ? null : childHref, parent.getTreeNodeId());
sub.isDirectory() ? null : childHref, length,
parent.getTreeNodeId());
r.tree.put(a, r.tree.remove(parent));
} else {
// Use null href for a directory:
a = new Artifact(child, childPath,
sub.isDirectory() ? null : childHref, "n" + ++r.idSeq);
sub.isDirectory() ? null : childHref, length,
"n" + ++r.idSeq);
r.tree.put(a, parent!=null ? parent.getTreeNodeId() : null);
}
if (sub.isDirectory()) {
......@@ -896,7 +899,7 @@ public abstract class Run <JobT extends Job<JobT,RunT>,RunT extends Run<JobT,Run
if (n>=upTo) break;
} else {
// Don't store collapsed path in ArrayList (for correct data in external API)
r.add(collapsed ? new Artifact(child, a.relativePath, a.href, a.treeNodeId) : a);
r.add(collapsed ? new Artifact(child, a.relativePath, a.href, length, a.treeNodeId) : a);
if (++n>=upTo) break;
}
}
......@@ -1031,11 +1034,17 @@ public abstract class Run <JobT extends Job<JobT,RunT>,RunT extends Run<JobT,Run
*/
private String treeNodeId;
/*package for test*/ Artifact(String name, String relativePath, String href, String treeNodeId) {
/**
*length of this artifact for files.
*/
private String length;
/*package for test*/ Artifact(String name, String relativePath, String href, String len, String treeNodeId) {
this.name = name;
this.relativePath = relativePath;
this.href = href;
this.treeNodeId = treeNodeId;
this.length = len;
}
/**
......@@ -1062,6 +1071,10 @@ public abstract class Run <JobT extends Job<JobT,RunT>,RunT extends Run<JobT,Run
return href;
}
public String getLength() {
return length;
}
public String getTreeNodeId() {
return treeNodeId;
}
......
......@@ -31,11 +31,21 @@ THE SOFTWARE.
<t:buildCaption>
${%Build Artifacts}
</t:buildCaption>
<ul>
<table class="fileList">
<j:forEach var="f" items="${it.artifacts}">
<li><a href="artifact/${f.href}">${f.displayPath}</a></li>
<tr>
<td>
<img src="${imagesURL}/16x16/text.png" alt="" height="16" width="16"/>
</td>
<td>
<a href="artifact/${f.href}">${f.displayPath}</a>
</td>
<td class="fileSize">
${f.length}
</td>
</tr>
</j:forEach>
</ul>
</table>
</l:main-panel>
</l:layout>
</j:if>
......
......@@ -47,15 +47,26 @@ THE SOFTWARE.
<j:choose>
<j:when test="${size(artifacts) le build.LIST_CUTOFF}">
<!-- if not too many, just list them -->
<ul>
<table class="fileList">
<j:forEach var="f" items="${artifacts}">
<li>
<a href="${baseURL}artifact/${f.href}">${f.displayPath}</a>
<st:nbsp/>
<a href="${baseURL}artifact/${f.href}/*fingerprint*/"><img src="${imagesURL}/16x16/fingerprint.png" alt="[fingerprint]" height="16" width="16" /></a>
</li>
<tr>
<td>
<img src="${imagesURL}/16x16/text.png" alt="" height="16" width="16"/>
</td>
<td>
<a href="${baseURL}artifact/${f.href}">${f.displayPath}</a>
</td>
<td class="fileSize">
${f.length}
</td>
<td>
<a href="${baseURL}artifact/${f.href}/*fingerprint*/">
<img src="${imagesURL}/16x16/fingerprint.png" alt="[fingerprint]" height="16" width="16"/>
</a>
</td>
</tr>
</j:forEach>
</ul>
</table>
</j:when>
<j:when test="${size(artifacts) le build.TREE_CUTOFF}">
<!-- otherwise (unless way too many) use a tree view -->
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册