--- trunk2/lib/WebPAC.pm 2004/09/14 17:07:59 441 +++ trunk2/lib/WebPAC.pm 2004/09/21 19:08:11 459 @@ -209,6 +209,8 @@ if (my $s = $self->{'start_mfn'}) { $log->info("skipping to MFN $s"); $startmfn = $s; + } else { + $self->{'start_mfn'} = $startmfn; } $maxmfn = $startmfn + $self->{limit_mfn} if ($self->{limit_mfn}); @@ -264,7 +266,7 @@ } - $self->{'current_mfn'} = $startmfn; + $self->{'current_mfn'} = -1; $self->{'last_pcnt'} = 0; $log->debug("max mfn: $maxmfn"); @@ -287,7 +289,15 @@ my $log = $self->_get_logger(); - my $mfn = $self->{'current_mfn'}++ || $log->logconfess("it seems that you didn't load database!"); + $log->logconfess("it seems that you didn't load database!") unless ($self->{'current_mfn'}); + + if ($self->{'current_mfn'} == -1) { + $self->{'current_mfn'} = $self->{'start_mfn'}; + } else { + $self->{'current_mfn'}++; + } + + my $mfn = $self->{'current_mfn'}; if ($mfn > $self->{'max_mfn'}) { $self->{'current_mfn'} = $self->{'max_mfn'}; @@ -304,6 +314,19 @@ } } +=head2 mfn + +Returns current record number (MFN). + + print $webpac->mfn; + +=cut + +sub mfn { + my $self = shift; + return $self->{'current_mfn'}; +} + =head2 progress_bar Draw progress bar on STDERR. @@ -329,15 +352,17 @@ $self->{'last_pcnt'} ||= 1; - my $p = int($curr * 100 / $max); + my $p = int($curr * 100 / $max) || 1; # reset on re-run if ($p < $self->{'last_pcnt'}) { $self->{'last_pcnt'} = $p; $self->{'last_t'} = time(); - $self->{'last_curr'} = 1; + $self->{'last_curr'} = undef; } + $self->{'last_t'} ||= time(); + if ($p != $self->{'last_pcnt'}) { my $last_curr = $self->{'last_curr'} || $curr;