o Tweaked transfer progress output

git-svn-id: https://svn.apache.org/repos/asf/maven/maven-3/trunk@829115 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Benjamin Bentmann 2009-10-23 16:10:41 +00:00
parent f5a93816c7
commit d8942acd68
2 changed files with 16 additions and 3 deletions

View File

@ -129,7 +129,7 @@ public abstract class AbstractMavenTransferListener
{
String type =
( transferEvent.getRequestType() == ArtifactTransferEvent.REQUEST_PUT ? "uploaded" : "downloaded" );
String l = contentLength >= 1024 ? ( ( contentLength + 1023 ) / 1024 ) + " KB" : contentLength + " B";
String l = contentLength >= 1024 ? toKB( contentLength ) + " KB" : contentLength + " B";
String throughput = "";
long duration = System.currentTimeMillis() - artifact.getTransferStartTime();
@ -144,6 +144,11 @@ public abstract class AbstractMavenTransferListener
}
}
protected long toKB( long bytes )
{
return ( bytes + 1023 ) / 1024;
}
public boolean isShowChecksumEvents()
{
return showChecksumEvents;

View File

@ -46,11 +46,19 @@ class ConsoleMavenTransferListener
// TODO [BP]: Sys.out may no longer be appropriate, but will \r work with getLogger()?
if ( total >= 1024 )
{
out.print( ( complete / 1024 ) + "/" + ( total == -1 ? "?" : ( total / 1024 ) + " KB" ) + "\r" );
out.print( toKB( complete ) + "/" + toKB( total ) + " KB" + "\r" );
}
else if ( total >= 0 )
{
out.print( complete + "/" + total + " B" + "\r" );
}
else if ( complete >= 1024 )
{
out.print( toKB( complete ) + " KB" + "\r" );
}
else
{
out.print( complete + "/" + ( total == -1 ? "?" : total + " B" ) + "\r" );
out.print( complete + " B" + "\r" );
}
}