Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#130: Added default content length to progress bar #285

Prev Previous commit
Next Next commit
renamed a method
  • Loading branch information
ndemirca committed Apr 11, 2024
commit 610c37de3fdd40c60af780c05d0b55923b682309
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public void download(String url, Path target) {
private void downloadFileWithProgressBar(String url, Path target, HttpResponse<InputStream> response) {

long contentLength = response.headers().firstValueAsLong("content-length").orElse(0);
informAboutDefaultMaxContentLength(contentLength);
informAboutSettingDefaultContentLength(contentLength);
byte[] data = new byte[1024];
boolean fileComplete = false;
int count;
Expand Down Expand Up @@ -150,7 +150,7 @@ private void copyFileWithProgressBar(Path source, Path target) throws IOExceptio
try (InputStream in = new FileInputStream(source.toFile()); OutputStream out = new FileOutputStream(target.toFile())) {

long size = source.toFile().length();
informAboutDefaultMaxContentLength(size);
informAboutSettingDefaultContentLength(size);

byte[] buf = new byte[1024];
int readBytes;
Expand All @@ -166,7 +166,7 @@ private void copyFileWithProgressBar(Path source, Path target) throws IOExceptio
}
}

private void informAboutDefaultMaxContentLength(long contentLength) {
private void informAboutSettingDefaultContentLength(long contentLength) {

if (contentLength == 0) {
this.context.warning("Content-Length was not provided by download/copy source. Using fallback: Content-Length for the progress bar is set to 10000000.");
Expand Down