Fix: do not spam the text ui with the same status

This commit is contained in:
Laurent Clouet
2024-05-03 11:11:40 +02:00
parent 65aeb07b7a
commit 1185fbc517

View File

@@ -45,6 +45,7 @@ public class GuiText implements Gui {
private Log log; private Log log;
private DateFormat df; private DateFormat df;
private String eta; private String eta;
private String statusOld; // buffer to avoid displaying the same info multiple time
private Client client; private Client client;
private DownloadProgress downloadProgress; private DownloadProgress downloadProgress;
@@ -55,6 +56,7 @@ public class GuiText implements Gui {
this.log = Log.getInstance(null); this.log = Log.getInstance(null);
this.df = new SimpleDateFormat("MMM dd HH:mm:ss"); this.df = new SimpleDateFormat("MMM dd HH:mm:ss");
this.eta = ""; this.eta = "";
this.statusOld = "";
} }
@Override public void start() { @Override public void start() {
@@ -115,7 +117,11 @@ public class GuiText implements Gui {
} }
} }
else { else {
System.out.println(String.format("%s %s", this.df.format(new Date()), msg_)); String statusNew = String.format("%s %s", this.df.format(new Date()), msg_);
if (statusOld.equals(statusNew) == false) {
statusOld = statusNew;
System.out.println(statusNew);
}
} }
} }