SVN: toys/rsget.pl/RSGet: Dispatch.pm FileList.pm Get.pm Processor.pm

sparky sparky at pld-linux.org
Sat Jun 26 01:31:12 CEST 2010


Author: sparky
Date: Sat Jun 26 01:31:12 2010
New Revision: 11576

Modified:
   toys/rsget.pl/RSGet/Dispatch.pm
   toys/rsget.pl/RSGet/FileList.pm
   toys/rsget.pl/RSGet/Get.pm
   toys/rsget.pl/RSGet/Processor.pm
Log:
- added DELAY() function, still somewhat unfinished


Modified: toys/rsget.pl/RSGet/Dispatch.pm
==============================================================================
--- toys/rsget.pl/RSGet/Dispatch.pm	(original)
+++ toys/rsget.pl/RSGet/Dispatch.pm	Sat Jun 26 01:31:12 2010
@@ -152,6 +152,14 @@
 	my ( $cmd, $uri, $getter, $options ) = @_;
 	my $class = $getter->{class};
 
+	if ( $options->{delay} ) {
+		if ( not $options->{error} or not $options->{error} =~ /^Delayed until/ ) {
+			delete $options->{delay};
+		} elsif ( $options->{delay} < time ) {
+			delete $options->{delay};
+			delete $options->{error};
+		}
+	}
 	return if $options->{error};
 
 	my $working = $working{ $cmd };
@@ -191,6 +199,7 @@
 {
 	my $getlist = shift;
 
+	my $time = shift;
 	my %num_by_pkg;
 	my %all_uris;
 	my $to_dl = 0;
@@ -216,7 +225,7 @@
 				if ( my $obj = $downloading{$uri} ) {
 					$obj->{_abort} = "Stopped";
 				}
-				next;
+				next unless $opts->{delay};
 			}
 			$all_uris{ $uri } = 1;
 			my $pkg = $getter->{pkg};

Modified: toys/rsget.pl/RSGet/FileList.pm
==============================================================================
--- toys/rsget.pl/RSGet/FileList.pm	(original)
+++ toys/rsget.pl/RSGet/FileList.pm	Sat Jun 26 01:31:12 2010
@@ -344,7 +344,7 @@
 		my $all_error = 1;
 		foreach my $uri ( keys %decoded ) {
 			my $options = $decoded{ $uri }->[1];
-			unless ( $options->{error} ) {
+			if ( not $options->{error} or $options->{delay} ) {
 				$all_error = 0;
 				last;
 			}

Modified: toys/rsget.pl/RSGet/Get.pm
==============================================================================
--- toys/rsget.pl/RSGet/Get.pm	(original)
+++ toys/rsget.pl/RSGet/Get.pm	Sat Jun 26 01:31:12 2010
@@ -263,6 +263,20 @@
 	return $self->wait( \&start, - irand( 60, 300 ), $msg, "multi" );
 }
 
+sub delay
+{
+	my $self = shift;
+	my $time = shift;
+	my $msg = shift;
+	$time = abs $time;
+	my $until = $time + time;
+	$msg = "Delayed until " . localtime( $until ) . ": " . $msg;
+
+	$self->print( $msg ) || $self->log( $msg );
+	RSGet::FileList::save( $self->{_uri}, options => { delay => $until, error => $msg } );
+	RSGet::Dispatch::finished( $self );
+}
+
 sub finish
 {
 	my $self = shift;

Modified: toys/rsget.pl/RSGet/Processor.pm
==============================================================================
--- toys/rsget.pl/RSGet/Processor.pm	(original)
+++ toys/rsget.pl/RSGet/Processor.pm	Sat Jun 26 01:31:12 2010
@@ -136,7 +136,7 @@
 			p_sub( $next_stage );
 			$_ = $left;
 			redo if /\S/;
-		} elsif ( s/^(ERROR|RESTART|LINK|MULTI)\s*\(// ) {
+		} elsif ( s/^(ERROR|RESTART|LINK|MULTI|DELAY)\s*\(// ) {
 			p_ret( lc $1 );
 			p_line();
 		} elsif ( s/^INFO\s*\(// ) {


More information about the pld-cvs-commit mailing list