Update of /cvsroot/fink/fink/perlmod/Fink
In directory sc8-pr-cvs17:/tmp/cvs-serv27170/perlmod/Fink

Modified Files:
        ChangeLog Engine.pm Mirror.pm 
Log Message:
* make self-update an alias for selfupdate
* skip mirrors which have failed 2 or more times (per session)
* timeout on mirror selection after 2 minutes


Index: Mirror.pm
===================================================================
RCS file: /cvsroot/fink/fink/perlmod/Fink/Mirror.pm,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -d -r1.29 -r1.30
--- Mirror.pm   11 Jan 2007 03:17:47 -0000      1.29
+++ Mirror.pm   28 Sep 2007 14:14:15 -0000      1.30
@@ -44,6 +44,8 @@
 }
 our @EXPORT_OK;
 
+our $MAX_MIRROR_FAILURE = 2;
+our $failed_mirrors = {};
 my %named_mirrors = ();
 
 END { }                                # module clean-up code here (global 
destructor)
@@ -261,13 +263,13 @@
        $self->{tries}++;
        $self->{failed}->{$self->{lastused}} = 1;
 
+       # if this hits $MAX_MIRROR_FAILURE, that mirror will be skipped in 
subsequent downloads
+       $failed_mirrors->{$self->{lastused}}++;
+
        # get lists of remaining mirrors
-       @list_country = grep { not exists $self->{failed}->{$_} }
-               $self->list_by_level(1);
-       @list_continent = grep { not exists $self->{failed}->{$_} }
-               $self->list_by_level(2);
-       @list_world = grep { not exists $self->{failed}->{$_} }
-               $self->list_by_level(3);
+       @list_country   = $self->list_not_failed_by_level(1);
+       @list_continent = $self->list_not_failed_by_level(2);
+       @list_world     = $self->list_not_failed_by_level(3);
 
        # assemble choices
        @choice_list = ( "error", "retry" );
@@ -319,18 +321,23 @@
                } else {
                        $nexttext = "Retry using next mirror set \"$next_set\"";
                }
-               my %choices = ( "error" => "Give up",
-                               "retry" => "Retry the same mirror",
-                               "retry-country" => "Retry another mirror from 
your country",
-                               "retry-continent" => "Retry another mirror from 
your continent",
-                               "retry-world" => "Retry another mirror",
-                               "retry-next" => $nexttext );
+               my %choices = (
+                       "error" => "Give up",
+                       "retry" => "Retry the same mirror",
+                       "retry-country" => "Retry another mirror from your 
country",
+                       "retry-continent" => "Retry another mirror from your 
continent",
+                       "retry-world" => "Retry another mirror",
+                       "retry-next" => $nexttext,
+               );
                my @choices = map { ( $choices{$_} => $_ ) } @choice_list;
                $result =
-               &prompt_selection("How do you want to proceed?",
-                                     default => [ number => $default ],
-                                     choices => [EMAIL PROTECTED],
-                                     category => 'fetch',);
+               &prompt_selection(
+                       "How do you want to proceed?",
+                       default  => [ number => $default ],
+                       choices  => [EMAIL PROTECTED],
+                       category => 'fetch',
+                       timeout  => 120,
+               );
        }
        $url = $self->{lastused};
        if ($result eq "error") {
@@ -377,6 +384,23 @@
 #                               2 - continent
 #                               3 - world (includes primaries)
 
+### list mirrors by level which have not
+# a) failed for this particular download and
+# b) failed at least $MAX_MIRROR_FAILURE times on any download
+
+sub list_not_failed_by_level {
+       my $self  = shift;
+       my $level = shift;
+
+       return grep {
+               not exists $self->{failed}->{$_} and
+               (
+                       not exists $failed_mirrors->{$_} or
+                       $failed_mirrors->{$_} < $MAX_MIRROR_FAILURE
+               )
+       } $self->list_by_level($level);
+}
+
 sub list_by_level {
        my $self = shift;
        my $level = shift;

Index: Engine.pm
===================================================================
RCS file: /cvsroot/fink/fink/perlmod/Fink/Engine.pm,v
retrieving revision 1.410
retrieving revision 1.411
diff -u -d -r1.410 -r1.411
--- Engine.pm   28 Aug 2007 13:23:10 -0000      1.410
+++ Engine.pm   28 Sep 2007 14:14:15 -0000      1.411
@@ -114,6 +114,7 @@
          'listpackages'      => [\&cmd_listpackages,      1, 0, 0],
          'plugins'           => [\&cmd_listplugins,       0, 0, 0],
          'selfupdate'        => [\&cmd_selfupdate,        0, 1, 1],
+         'self-update'       => [\&cmd_selfupdate,        0, 1, 1],
          'selfupdate-cvs'    => [\&cmd_selfupdate_cvs,    0, 1, 1],
          'selfupdate-rsync'  => [\&cmd_selfupdate_rsync,  0, 1, 1],
          'selfupdate-finish' => [\&cmd_selfupdate_finish, 1, 1, 1],

Index: ChangeLog
===================================================================
RCS file: /cvsroot/fink/fink/perlmod/Fink/ChangeLog,v
retrieving revision 1.1493
retrieving revision 1.1494
diff -u -d -r1.1493 -r1.1494
--- ChangeLog   18 Sep 2007 14:13:19 -0000      1.1493
+++ ChangeLog   28 Sep 2007 14:14:14 -0000      1.1494
@@ -1,3 +1,8 @@
+2007-09-28  Benjamin Reed  <[EMAIL PROTECTED]>
+
+       * Engine.pm, Mirror.pm: Implement *cough* "feature requests" from
+       http://tdk.hates-software.com/2007/09/28/a3fbc1b7.html    ;)
+
 2007-09-18  Daniel Macks  <[EMAIL PROTECTED]>
 
        * Validation.pm: Detect .deb containing global file updated at


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Fink-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/fink-commits

Reply via email to