SVN: toys/rsget.pl/RSGet: Curl.pm Dispatch.pm Get.pm
sparky
sparky at pld-linux.org
Mon Dec 6 20:19:11 CET 2010
Author: sparky
Date: Mon Dec 6 20:19:10 2010
New Revision: 11967
Modified:
toys/rsget.pl/RSGet/Curl.pm
toys/rsget.pl/RSGet/Dispatch.pm
toys/rsget.pl/RSGet/Get.pm
Log:
- implemented soft restart - SIGUSR2 will make rsget.pl restart after
finishing all current downloads
Modified: toys/rsget.pl/RSGet/Curl.pm
==============================================================================
--- toys/rsget.pl/RSGet/Curl.pm (original)
+++ toys/rsget.pl/RSGet/Curl.pm Mon Dec 6 20:19:10 2010
@@ -392,7 +392,7 @@
size_got => $start,
time_stamp => [ $time, $start, $time, $start, $time, $start ];
- RSGet::FileList::update(); # to update statistics
+ $get_obj->started_download( fname => $supercurl->{fname}, fsize => $supercurl->{size_total} );
return;
}
} else {
Modified: toys/rsget.pl/RSGet/Dispatch.pm
==============================================================================
--- toys/rsget.pl/RSGet/Dispatch.pm (original)
+++ toys/rsget.pl/RSGet/Dispatch.pm Mon Dec 6 20:19:10 2010
@@ -29,6 +29,8 @@
our %downloading;
our %checking;
+my $soft_restart = 0;
+
my %working = (
get => \%downloading,
check => \%checking,
@@ -248,12 +250,26 @@
}
abort_missing( \%all_uris, \%downloading );
+
+ my $downloading_num = scalar grep { $_->{started_download} } values %downloading;
RSGet::Line::status(
'to download' => $to_dl,
- 'downloading' => scalar keys %downloading,
+ 'running' => scalar keys %downloading,
+ 'downloading' => $downloading_num,
'checking URIs' => scalar keys %checking,
);
+ if ( $soft_restart ) {
+ foreach my $obj ( values %downloading ) {
+ unless ( $obj->{started_download} ) {
+ $obj->{_abort} = "Soft restart";
+ }
+ }
+ RSGet::Main::restart()
+ unless $downloading_num;
+ return 1;
+ }
+
my $all_checked = 1;
EACH_LINE: foreach my $line ( @$getlist ) {
next unless ref $line;
@@ -291,6 +307,15 @@
return $all_checked;
}
+sub soft_restart
+{
+ $soft_restart = 1;
+ new RSGet::Line( "NOTICE: ", "rsget.pl will restart after finishing all current downloads" );
+ RSGet::FileList::update();
+}
+
+$SIG{USR2} = \&soft_restart;
+
sub abort_missing
{
my $all = shift;
Modified: toys/rsget.pl/RSGet/Get.pm
==============================================================================
--- toys/rsget.pl/RSGet/Get.pm (original)
+++ toys/rsget.pl/RSGet/Get.pm Mon Dec 6 20:19:10 2010
@@ -77,6 +77,8 @@
bless $self, $getter->{pkg};
$self->bestinfo();
+ RSGet::FileList::update();
+
if ( verbose( 2 ) or $cmd eq "get" ) {
my $outifstr = $outif ? "[$outif]" : "";
@@ -474,6 +476,8 @@
my @osize;
@osize = ( fsize => $fsize ) if $fsize > 0;
+ $self->{started_download} = 1;
+
RSGet::FileList::save( $self->{_uri},
globals => { fname => $fname, fsize => $fsize },
options => { fname => $fname, @osize } );
More information about the pld-cvs-commit
mailing list