AnsweredAssumed Answered

Announce a progress bar bug for file transfer

Question asked by michaelpan on May 12, 2011
Latest reply on May 12, 2011 by Wolf

I found that when the file size is more than 2G bytes, the progress bar for file transfer would not work normally.

Fortunately, the bytes counter worked correctly.

 

Finally, I found the answer of this bug in the source code of Spark.

 

 

At line 185 in org.jivesoftware.sparkimpl.plugin.filetransfer.transfer.ui.SendMessage.java

progressBar.setMaximum((int)fileSize);

and line 275

progressBar.setValue((int)transfer.getBytesSent());

 

At line 235 in org.jivesoftware.sparkimpl.plugin.filetransfer.transfer.ui.ReceiveMessage.java

progressBar.setMaximum((int)request.getFileSize());

and line 267

progressBar.setValue((int)bytesRead);

 

 

Because the maximum number of 'int' in java is only 2G-1, the progress bar will not work normally with larger than 2G bytes file transfered.

 

I think, here we should increase the progress in kilo-bytes, i.e. the source code should change to

At line 185 in org.jivesoftware.sparkimpl.plugin.filetransfer.transfer.ui.SendMessage.java

 

progressBar.setMaximum((int) (fileSize/1024) );

and line 275

progressBar.setValue((int) (transfer.getBytesSent()/1024) );

 

At line 235 in org.jivesoftware.sparkimpl.plugin.filetransfer.transfer.ui.ReceiveMessage.java

progressBar.setMaximum((int) (request.getFileSize()/1024) );

and line 267

progressBar.setValue((int) (bytesRead/1024) );

 

Then, it will be OK for files with size of less than 1T bytes.

 

Additionally, I have a suggesstion.

It will be better that the string displayed in progress bar is as this format: bytes received(sent) @ transfer speed.

For example:

2.1M bytes received(sent) @ 200k/s.

 

When a large file is transferring, the bytes received(sent) number increases slowly at G bytes.

So, if speed is used, users will treat the transferring working normally, not stuck, isn't it?

Outcomes