Added logging for % downloaded

This commit is contained in:
coolGi
2023-11-20 21:59:01 +10:30
parent 1ebbd9f7e4
commit 8af14ad3e7
3 changed files with 11 additions and 6 deletions
@@ -25,7 +25,6 @@ import com.seibel.distanthorizons.core.config.ConfigBase;
import com.seibel.distanthorizons.core.config.types.AbstractConfigType;
import com.seibel.distanthorizons.core.config.types.ConfigEntry;
import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftClientWrapper;
import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftSharedWrapper;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@@ -112,7 +111,7 @@ public class ConfigFileHandling
// Attempt to get the version number
currentCfgVersion = (Integer) tmpNightConfig.get("_version");
tmpNightConfig.close();
} catch (Exception e) {e.printStackTrace();}
} catch (Exception ignored) { }
if (currentCfgVersion == configBase.configVersion)
{}
@@ -74,13 +74,19 @@ public class WebDownloader
fos, 1024))
{
byte[] data = new byte[1024];
int i;
int i, percent = -1;
while ((i = in.read(data, 0, 1024)) >= 0)
{
totalDataRead = totalDataRead + i;
bout.write(data, 0, i);
// int percent = (int) ((totalDataRead * 100) / filesize);
// System.out.println(percent);
// TODO: Link this to an atomic integer rather than printing it to log
int newPercent = (int) ((totalDataRead * 100) / filesize);
if (percent != newPercent)
{
percent = newPercent;
System.out.println(String.valueOf(percent) +"% downloaded");
}
}
}
}
@@ -141,7 +141,7 @@ public class SelfUpdater
if (!pipeline.get("status").equals("success"))
{
LOGGER.warn("Pipeline for branch ["+ ModJarInfo.Git_Branch +"], commit ["+ pipeline.get("id") +"], has either failed to build, or still building.");
LOGGER.warn("Pipeline for branch ["+ ModJarInfo.Git_Branch +"], pipeline ID ["+ pipeline.get("id") +"], has either failed to build, or is still building.");
return false;
}