mirror of
https://github.com/apache/maven-mvnd.git
synced 2025-09-10 04:59:54 +00:00
This commit is contained in:
@@ -787,7 +787,7 @@ public abstract class Message {
|
||||
public static final int PUT = 2;
|
||||
|
||||
final String projectId;
|
||||
final int request;
|
||||
final int requestType;
|
||||
final String repositoryId;
|
||||
final String repositoryUrl;
|
||||
final String resourceName;
|
||||
@@ -795,13 +795,13 @@ public abstract class Message {
|
||||
final long transferredBytes;
|
||||
final String exception;
|
||||
|
||||
private TransferEvent(int type, String projectId, int request,
|
||||
private TransferEvent(int type, String projectId, int requestType,
|
||||
String repositoryId, String repositoryUrl,
|
||||
String resourceName, long contentLength, long transferredBytes,
|
||||
String exception) {
|
||||
super(type);
|
||||
this.projectId = projectId;
|
||||
this.request = request;
|
||||
this.requestType = requestType;
|
||||
this.repositoryId = repositoryId;
|
||||
this.repositoryUrl = repositoryUrl;
|
||||
this.resourceName = resourceName;
|
||||
@@ -814,8 +814,8 @@ public abstract class Message {
|
||||
return projectId;
|
||||
}
|
||||
|
||||
public int getRequest() {
|
||||
return request;
|
||||
public int getRequestType() {
|
||||
return requestType;
|
||||
}
|
||||
|
||||
public String getRepositoryId() {
|
||||
@@ -846,7 +846,7 @@ public abstract class Message {
|
||||
public String toString() {
|
||||
return mnemonic() + "{" +
|
||||
"projectId=" + projectId +
|
||||
", request=" + request +
|
||||
", requestType=" + requestType +
|
||||
", repositoryId='" + repositoryId + '\'' +
|
||||
", repositoryUrl='" + repositoryUrl + '\'' +
|
||||
", resourceName='" + resourceName + '\'' +
|
||||
@@ -879,7 +879,7 @@ public abstract class Message {
|
||||
public void write(DataOutputStream output) throws IOException {
|
||||
super.write(output);
|
||||
writeUTF(output, projectId);
|
||||
output.writeByte(request);
|
||||
output.writeByte(requestType);
|
||||
writeUTF(output, repositoryId);
|
||||
writeUTF(output, repositoryUrl);
|
||||
writeUTF(output, resourceName);
|
||||
@@ -943,11 +943,11 @@ public abstract class Message {
|
||||
return new ProjectEvent(Message.DISPLAY, projectId, message);
|
||||
}
|
||||
|
||||
public static TransferEvent transfer(String projectId, int event, int request,
|
||||
public static TransferEvent transfer(String projectId, int transferEventType, int requestType,
|
||||
String repositoryId, String repositoryUrl,
|
||||
String resourceName, long contentLength, long transferredBytes,
|
||||
String exception) {
|
||||
return new TransferEvent(event, projectId, request,
|
||||
return new TransferEvent(transferEventType, projectId, requestType,
|
||||
repositoryId, repositoryUrl, resourceName, contentLength, transferredBytes, exception);
|
||||
}
|
||||
|
||||
|
@@ -33,14 +33,24 @@ public class OsUtils {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(OsUtils.class);
|
||||
private static final long KB = 1024;
|
||||
private static final String UNITS = "kmgt";
|
||||
private static final String UNITS = "Bkmgt";
|
||||
|
||||
private OsUtils() {
|
||||
|
||||
}
|
||||
|
||||
public static String kbTohumanReadable(long kb) {
|
||||
public static String bytesTohumanReadable(long bytes) {
|
||||
int unit = 0;
|
||||
while (bytes >= KB && unit < UNITS.length() - 1) {
|
||||
bytes /= KB;
|
||||
unit++;
|
||||
}
|
||||
String kbString = String.valueOf(bytes);
|
||||
return new StringBuilder(kbString.length() + 1).append(kbString).append(UNITS.charAt(unit)).toString();
|
||||
}
|
||||
|
||||
public static String kbTohumanReadable(long kb) {
|
||||
int unit = 1;
|
||||
while (kb >= KB && unit < UNITS.length() - 1) {
|
||||
kb /= KB;
|
||||
unit++;
|
||||
|
@@ -531,25 +531,26 @@ public class TerminalOutput implements ClientOutput {
|
||||
return null;
|
||||
}
|
||||
TransferEvent event = transfers.iterator().next();
|
||||
String action = event.getRequest() == TransferEvent.PUT ? "Uploading" : "Downloading";
|
||||
String action = event.getRequestType() == TransferEvent.PUT ? "Uploading" : "Downloading";
|
||||
if (transfers.size() == 1) {
|
||||
String direction = event.getRequest() == TransferEvent.PUT ? "to" : "from";
|
||||
String direction = event.getRequestType() == TransferEvent.PUT ? "to" : "from";
|
||||
long cur = event.getTransferredBytes();
|
||||
long max = event.getContentLength();
|
||||
String prg = OsUtils.kbTohumanReadable(cur / 1024) + " / " + OsUtils.kbTohumanReadable(max / 1024);
|
||||
AttributedStringBuilder asb = new AttributedStringBuilder();
|
||||
asb.append(action);
|
||||
asb.append(" ");
|
||||
asb.append(' ');
|
||||
asb.style(AttributedStyle.BOLD);
|
||||
asb.append(pathToMaven(event.getResourceName()));
|
||||
asb.style(AttributedStyle.DEFAULT);
|
||||
asb.append(" ");
|
||||
asb.append(' ');
|
||||
asb.append(direction);
|
||||
asb.append(" ");
|
||||
asb.append(' ');
|
||||
asb.append(event.getRepositoryId());
|
||||
if (cur > 0 && cur < max) {
|
||||
asb.append(": ");
|
||||
asb.append(prg);
|
||||
asb.append(' ');
|
||||
asb.append(OsUtils.bytesTohumanReadable(cur));
|
||||
asb.append('/');
|
||||
asb.append(OsUtils.bytesTohumanReadable(max));
|
||||
}
|
||||
return asb.toAttributedString();
|
||||
} else {
|
||||
|
Reference in New Issue
Block a user