diff options
author | Pascal Rigaux <pixel@mandriva.com> | 2006-11-13 15:46:08 +0000 |
---|---|---|
committer | Pascal Rigaux <pixel@mandriva.com> | 2006-11-13 15:46:08 +0000 |
commit | e5bcf4f42d3b8233a1fcf967207dcf4845ebe9f0 (patch) | |
tree | d021547181530da370b8a1c0ea650e9a1de7733b | |
parent | f15b9b4cd5c6d464ac082c4b505156046b03d0c1 (diff) | |
download | urpmi-e5bcf4f42d3b8233a1fcf967207dcf4845ebe9f0.tar urpmi-e5bcf4f42d3b8233a1fcf967207dcf4845ebe9f0.tar.gz urpmi-e5bcf4f42d3b8233a1fcf967207dcf4845ebe9f0.tar.bz2 urpmi-e5bcf4f42d3b8233a1fcf967207dcf4845ebe9f0.tar.xz urpmi-e5bcf4f42d3b8233a1fcf967207dcf4845ebe9f0.zip |
factorize code into _read_existing_synthesis_and_hdlist_if_same_time_and_msize() and _read_existing_synthesis_and_hdlist()
-rw-r--r-- | urpm.pm | 50 |
1 files changed, 23 insertions, 27 deletions
@@ -1119,6 +1119,17 @@ sub generate_media_names { } +sub _read_existing_synthesis_and_hdlist_if_same_time_and_msize { + my ($urpm, $medium, $basename) = @_; + + same_size_and_mtime("$urpm->{cachedir}/partial/$basename", + "$urpm->{statedir}/$medium->{hdlist}") or return; + + _read_existing_synthesis_and_hdlist($urpm, $medium, $basename); + + 1; +} + sub _read_existing_synthesis_and_hdlist_if_same_md5sum { my ($urpm, $medium, $basename, $retrieved_md5sum) = @_; @@ -1128,6 +1139,14 @@ sub _read_existing_synthesis_and_hdlist_if_same_md5sum { #- download hdlist or synthesis file again. $retrieved_md5sum && $medium->{md5sum} eq $retrieved_md5sum or return; + _read_existing_synthesis_and_hdlist($urpm, $medium, $basename); + + 1; +} + +sub _read_existing_synthesis_and_hdlist { + my ($urpm, $medium, $basename) = @_; + unlink "$urpm->{cachedir}/partial/$basename"; #- the medium is now considered not modified. $medium->{modified} = 0; @@ -1363,20 +1382,8 @@ this could happen if you mounted manually the directory when creating the medium #- check if the files are equal... and no force copy... if (!$error && !$options{force} && -e "$urpm->{statedir}/synthesis.$medium->{hdlist}") { - if (same_size_and_mtime("$urpm->{cachedir}/partial/$medium->{hdlist}", - "$urpm->{statedir}/$medium->{hdlist}")) { - #- the two files are considered equal here, the medium is so not modified. - $medium->{modified} = 0; - unlink "$urpm->{cachedir}/partial/$medium->{hdlist}"; - #- as previously done, just read synthesis file here, this is enough, but only - #- if synthesis exists, else it needs to be recomputed. - _parse_synthesis($urpm, $medium, "$urpm->{statedir}/synthesis.$medium->{hdlist}"); - if (!is_valid_medium($medium)) { - _parse_hdlist($urpm, $medium, "$urpm->{statedir}/$medium->{hdlist}", packing => 1); - _check_after_reading_hdlist_or_synthesis($urpm, $medium); - } - return; - } + _read_existing_synthesis_and_hdlist_if_same_time_and_msize($urpm, $medium, $medium->{hdlist}) + and return; } } else { $error = 1; @@ -1603,19 +1610,8 @@ this could happen if you mounted manually the directory when creating the medium $urpm->{log}(N("...retrieving done")); unless ($options{force}) { - if (same_size_and_mtime("$urpm->{cachedir}/partial/$basename", - "$urpm->{statedir}/$medium->{hdlist}")) { - #- the two files are considered equal here, the medium is so not modified. - $medium->{modified} = 0; - unlink "$urpm->{cachedir}/partial/$basename"; - #- as previously done, just read synthesis file here, this is enough. - _parse_synthesis($urpm, $medium, "$urpm->{statedir}/synthesis.$medium->{hdlist}"); - if (!is_valid_medium($medium)) { - _parse_hdlist($urpm, $medium, "$urpm->{statedir}/$medium->{hdlist}", packing => 1); - _check_after_reading_hdlist_or_synthesis($urpm, $medium); - } - return; - } + _read_existing_synthesis_and_hdlist_if_same_time_and_msize($urpm, $medium, $basename) + and return; } #- the files are different, update local copy. |