arrizer / PutIO-Perl-folder-sync

4 stars 1 forks source link

Download progress exceeds 100% #3

Closed arrizer closed 12 years ago

arrizer commented 12 years ago

The download progress is not calculated correctly for some files.

Pro commented 12 years ago

The reason for this is the wrong speed and size calculation. It shows > 7 MiB/s, but I have only max 2 MiB/s Already downloaded: 13GB, but file has only 7GB

seanlabastille commented 12 years ago

I believe the flaw is here:

sub downloadFile
{
  my $url = shift;
  my $filename = shift;

  $agent->add_handler(response_header => \&didReceiveResponse);
  $agent->add_handler(response_data => \&didReceiveData);
  $agent->credentials("put.io:80", "Put.io File Space", $config->{"account_name"}, $config->{"account_password"});

The handler is added every time a file is downloaded, thus it ends up being called several times each tick. The value shown seemed to be pretty close to n*(actual) for the n-th file being downloaded.