From baeec0542495b5b631fbd629f0fb0d8497a6ef47 Mon Sep 17 00:00:00 2001 From: Rafael Garcia-Suarez Date: Wed, 4 Jan 2006 12:15:00 +0000 Subject: Refactoring --- urpm.pm | 51 +++++++++++++++++++++------------------------------ 1 file changed, 21 insertions(+), 30 deletions(-) (limited to 'urpm.pm') diff --git a/urpm.pm b/urpm.pm index 31fdbc28..b23cb6c0 100644 --- a/urpm.pm +++ b/urpm.pm @@ -1214,21 +1214,7 @@ this could happen if you mounted manually the directory when creating the medium unless ($medium->{virtual}) { if ($medium->{with_hdlist}) { if (!$options{nomd5sum} && -s reduce_pathname("$with_hdlist_dir/../MD5SUM") > 32) { - if ($options{force}) { - #- force downloading the file again, else why a force option has been defined ? - delete $medium->{md5sum}; - } else { - unless ($medium->{md5sum}) { - $urpm->{log}(N("computing md5sum of existing source hdlist (or synthesis)")); - if ($medium->{synthesis}) { - -e "$urpm->{statedir}/synthesis.$medium->{hdlist}" and - $medium->{md5sum} = md5sum("$urpm->{statedir}/synthesis.$medium->{hdlist}"); - } else { - -e "$urpm->{statedir}/$medium->{hdlist}" and - $medium->{md5sum} = md5sum("$urpm->{statedir}/$medium->{hdlist}"); - } - } - } + recompute_local_md5sum($urpm, $medium, $options{force}); if ($medium->{md5sum}) { $retrieved_md5sum = parse_md5sum($urpm, reduce_pathname("$with_hdlist_dir/../MD5SUM"), $basename); #- If an existing hdlist or synthesis file has the same md5sum, we assume @@ -1488,21 +1474,7 @@ this could happen if you mounted manually the directory when creating the medium } }; if (!$@ && -e "$urpm->{cachedir}/partial/MD5SUM" && -s _ > 32) { - if ($options{force} >= 2) { - #- force downloading the file again, else why a force option has been defined ? - delete $medium->{md5sum}; - } else { - unless ($medium->{md5sum}) { - $urpm->{log}(N("computing md5sum of existing source hdlist (or synthesis)")); - if ($medium->{synthesis}) { - -e "$urpm->{statedir}/synthesis.$medium->{hdlist}" and - $medium->{md5sum} = md5sum("$urpm->{statedir}/synthesis.$medium->{hdlist}"); - } else { - -e "$urpm->{statedir}/$medium->{hdlist}" and - $medium->{md5sum} = md5sum("$urpm->{statedir}/$medium->{hdlist}"); - } - } - } + recompute_local_md5sum($urpm, $medium, $options{force} >= 2); if ($medium->{md5sum}) { $retrieved_md5sum = parse_md5sum($urpm, "$urpm->{cachedir}/partial/MD5SUM", $basename); #- if an existing hdlist or synthesis file has the same md5sum, we assume the @@ -3406,6 +3378,25 @@ sub parse_md5sum { return $retrieved_md5sum; } +sub recompute_local_md5sum { + my ($urpm, $medium, $force) = @_; + if ($force) { + #- force downloading the file again, else why a force option has been defined ? + delete $medium->{md5sum}; + } else { + unless ($medium->{md5sum}) { + $urpm->{log}(N("computing md5sum of existing source hdlist (or synthesis)")); + if ($medium->{synthesis}) { + -e "$urpm->{statedir}/synthesis.$medium->{hdlist}" and + $medium->{md5sum} = md5sum("$urpm->{statedir}/synthesis.$medium->{hdlist}"); + } else { + -e "$urpm->{statedir}/$medium->{hdlist}" and + $medium->{md5sum} = md5sum("$urpm->{statedir}/$medium->{hdlist}"); + } + } + } +} + sub syserror { my ($urpm, $msg, $info) = @_; $urpm->{error}("$msg [$info] [$!]") } sub open_safe { -- cgit v1.2.1