Skip to content
Permalink
Browse files
[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: Stephen Ware <stephen.e.ware@intel.com>
  • Loading branch information
seware authored and kohsuke committed Sep 13, 2011
1 parent 37a22a1 commit 94cbf5baf8640ff748332fb7799de2a978c72584
@@ -63,6 +63,9 @@
<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,25 +878,28 @@ private int addArtifacts( File dir, String path, String pathHref, ArtifactList r
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()) {
n += addArtifacts(sub, childPath + '/', childHref + '/', r, a, upTo-n);
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 @@ private String combineLast(String[] token, int n) {
*/
private String treeNodeId;

/*package for test*/ Artifact(String name, String relativePath, String href, String treeNodeId) {

This comment has been minimized.

Copy link
@orrc

orrc Sep 13, 2011

Member

Looks like removing this method signature broke the test case:
http://ci.jenkins-ci.org/job/jenkins_main_trunk/1125/console

/**
*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 String getHref() {
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 -->

0 comments on commit 94cbf5b

Please sign in to comment.