Changeset 17197 for trunk/base


Ignore:
Timestamp:
Mar 27, 2006, 9:32:27 PM (18 years ago)
Author:
jberry
Message:

Add a hack to help resolve problems in fetching from sourceforge mirrors.

If we receive a redirect during a fetch, and the url has sourceforge in it,
and the url redirected to contains the words "failedmirror" then assume this
was actually a sourceforge mirror failure, and continue to attempt the fetch
at more mirrors.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/base/src/port1.0/portfetch.tcl

    r14583 r17197  
    11# et:ts=4
    22# portfetch.tcl
    3 # $Id: portfetch.tcl,v 1.107 2005/10/12 22:10:28 pguyot Exp $
     3# $Id: portfetch.tcl,v 1.108 2006/03/27 21:32:27 jberry Exp $
    44#
    55# Copyright (c) 2002 - 2003 Apple Computer, Inc.
     
    400400                                global portfetch::$url_var
    401401                        }
     402                        unset -nocomplain fetched
    402403                        foreach site [set $url_var] {
    403404                                ui_msg "$UI_PREFIX [format [msgcat::mc "Attempting to fetch %s from %s"] $distfile $site]"
    404405                                set file_url [portfetch::assemble_url $site $distfile]
    405                                 if {![catch {eval curl fetch $fetch_options {$file_url} ${distpath}/${distfile}.TMP} result] &&
     406                                set effectiveURL ""
     407                                if {![catch {eval curl fetch --effective-url effectiveURL $fetch_options {$file_url} ${distpath}/${distfile}.TMP} result] &&
    406408                                        ![catch {system "mv ${distpath}/${distfile}.TMP ${distpath}/${distfile}"}]} {
    407                                         set fetched 1
    408                                         break
     409
     410                                        # Special hack to check for sourceforge mirrors, which don't return a proper error code on failure
     411                                        if {![string equal $effectiveURL $file_url] &&
     412                                                [string match "*sourceforge*" $file_url] &&
     413                                                [string match "*failedmirror*" $effectiveURL]} {
     414                                               
     415                                                # *SourceForge hackage in effect*
     416                                                # The url seen by curl seems to have been a redirect to the sourceforge mirror page
     417                                                ui_debug "[msgcat::mc "Fetching from sourceforge mirror failed"]"
     418                                                exec rm -f ${distpath}/${distfile}.TMP
     419                                               
     420                                                # Continue on to try the next mirror, if any
     421                                        } else {
     422                                       
     423                                                # Successful fetch
     424                                                set fetched 1
     425                                                break
     426                                       
     427                                        }
     428
    409429                                } else {
    410430                                        ui_debug "[msgcat::mc "Fetching failed:"]: $result"
     
    414434                        if {![info exists fetched]} {
    415435                                return -code error [msgcat::mc "fetch failed"]
    416                         } else {
    417                                 unset fetched
    418436                        }
    419437                }
Note: See TracChangeset for help on using the changeset viewer.