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

Improve Progress Visualisation during Zip Extraction #2085

Open
madoar opened this issue Sep 12, 2019 · 1 comment
Open

Improve Progress Visualisation during Zip Extraction #2085

madoar opened this issue Sep 12, 2019 · 1 comment

Comments

@madoar
Copy link
Collaborator

madoar commented Sep 12, 2019

Currently we update the progress bar during a zip archive extraction only after a complete file has been fully extracted. This leads to visible jumps in the progress bar which does not look really smooth to the user.

To improve on this we can replace the current

Files.copy(in, targetPath, StandardCopyOption.REPLACE_EXISTING);

Operation with a loop that manually copies the file content byte block for byte block. This allows us to update the progress bar more often to give the user a more smooth feeling.

Here an example how a byte stream can be manually copied in byte blocks (copied from #2064 (comment)):

long counter = 0;
int r = 0;
byte[] b = new byte[1024];
fin  = new FileInputStream(filein);
fout = new FileOutputStream(fileout);
while( (r = fin.read(b)) != -1) {
   counter += r;
   // update the progress bar
   fout.write(b, 0, r);
}

Notes:
I'm not sure if counter contains the number of compressed or uncompressed bytes...
Additionally the input stream wouldn't be of type FileInputStream. Instead it would be of whatever type apache-compress gives us

@plata
Copy link
Collaborator

plata commented Sep 16, 2019

To test, use a big archive like in PhoenicisOrg/scripts#1081.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants