diff options
author | lpsolit%gmail.com <> | 2007-04-18 05:13:22 +0000 |
---|---|---|
committer | lpsolit%gmail.com <> | 2007-04-18 05:13:22 +0000 |
commit | 0e2a60dc182c15159110e996b370fe1640af0fa4 (patch) | |
tree | d01fc40e5cdd24640ec5eb42675783d9f7121533 /Bugzilla/Update.pm | |
parent | Bug 258647: productmenu.js and productform.js should be consolidated - Patch ... (diff) | |
download | bugzilla-0e2a60dc182c15159110e996b370fe1640af0fa4.tar.gz bugzilla-0e2a60dc182c15159110e996b370fe1640af0fa4.tar.bz2 bugzilla-0e2a60dc182c15159110e996b370fe1640af0fa4.zip |
Bug 350112: Error about "data/bugzilla-update.xml" being unreadable - Patch by Frédéric Buclin <LpSolit@gmail.com> r=kevin.benton r=mkanat a=LpSolit
Diffstat (limited to 'Bugzilla/Update.pm')
-rw-r--r-- | Bugzilla/Update.pm | 30 |
1 files changed, 26 insertions, 4 deletions
diff --git a/Bugzilla/Update.pm b/Bugzilla/Update.pm index e5d4f86f9..596290ab9 100644 --- a/Bugzilla/Update.pm +++ b/Bugzilla/Update.pm @@ -46,7 +46,9 @@ sub get_notifications { $can_alter = utime(undef, undef, $local_file); } if ($can_alter) { - _synchronize_data(); + my $error = _synchronize_data(); + # If an error is returned, leave now. + return $error if $error; } else { return {'error' => 'no_update', 'xml_file' => $local_file}; @@ -130,14 +132,22 @@ sub get_notifications { sub _synchronize_data { eval("require LWP::UserAgent"); - return if $@; + return {'error' => 'missing_package', 'package' => 'LWP::UserAgent'} if $@; my $local_file = bz_locations()->{'datadir'} . LOCAL_FILE; my $ua = LWP::UserAgent->new(); $ua->timeout(TIMEOUT); $ua->protocols_allowed(['http', 'https']); - $ua->env_proxy; + # If the URL of the proxy is given, use it, else get this information + # from the environment variable. + my $proxy_url = Bugzilla->params->{'proxy_url'}; + if ($proxy_url) { + $ua->proxy(['http', 'https'], $proxy_url); + } + else { + $ua->env_proxy; + } $ua->mirror(REMOTE_FILE, $local_file); # $ua->mirror() forces the modification time of the local XML file @@ -145,7 +155,19 @@ sub _synchronize_data { # So we have to update it manually to reflect that a newer version # of the file has effectively been requested. This will avoid # any new download for the next TIME_INTERVAL. - utime(undef, undef, $local_file); + if (-e $local_file) { + # Try to alter its last modification time. + my $can_alter = utime(undef, undef, $local_file); + # This error should never happen. + $can_alter || return {'error' => 'no_update', 'xml_file' => $local_file}; + } + else { + # We have been unable to download the file. + return {'error' => 'cannot_download', 'xml_file' => $local_file}; + } + + # Everything went well. + return 0; } sub _compare_versions { |