diff options
author | Pascal Rigaux <pixel@mandriva.com> | 2008-09-23 07:26:26 +0000 |
---|---|---|
committer | Pascal Rigaux <pixel@mandriva.com> | 2008-09-23 07:26:26 +0000 |
commit | 367f0ff1ed2653ad0bfb62ba9156aea78eb24803 (patch) | |
tree | a49389e58a64dc0d1625bbeb801eaa75ffe4251f /urpm | |
parent | a1dca5cbe9076b19ca716ed6d66f7ba6670302d4 (diff) | |
download | urpmi-367f0ff1ed2653ad0bfb62ba9156aea78eb24803.tar urpmi-367f0ff1ed2653ad0bfb62ba9156aea78eb24803.tar.gz urpmi-367f0ff1ed2653ad0bfb62ba9156aea78eb24803.tar.bz2 urpmi-367f0ff1ed2653ad0bfb62ba9156aea78eb24803.tar.xz urpmi-367f0ff1ed2653ad0bfb62ba9156aea78eb24803.zip |
- normalize synthesis downloading: rename it in cachedir asap just like any other media_info files
- create urpm::download::sync_rel_to()
Diffstat (limited to 'urpm')
-rw-r--r-- | urpm/download.pm | 15 | ||||
-rw-r--r-- | urpm/media.pm | 13 |
2 files changed, 22 insertions, 6 deletions
diff --git a/urpm/download.pm b/urpm/download.pm index c1b07820..fe6097dd 100644 --- a/urpm/download.pm +++ b/urpm/download.pm @@ -836,6 +836,21 @@ sub sync_url { sync_rel($urpm, { url => dirname($url) }, [basename($url)], %options); } +sub sync_rel_to { + my ($urpm, $medium, $rel_file, $dest_file, %options) = @_; + + my $download_dir = $options{dir} || "$urpm->{cachedir}/partial"; + my $result_file = "$download_dir/" . basename($rel_file); + + if (sync_rel($urpm, $medium, [$rel_file], %options)) { + $result_file ne $dest_file or rename($result_file, $dest_file) or return; + 1; + } else { + unlink $result_file; + undef; + } +} + #- deprecated, use sync_url() or sync_rel() instead #- #- $medium can be undef diff --git a/urpm/media.pm b/urpm/media.pm index 16e7b5f1..3f90478c 100644 --- a/urpm/media.pm +++ b/urpm/media.pm @@ -377,7 +377,7 @@ sub statedir_xml_info { } sub cachedir_with_synthesis { my ($urpm, $medium) = @_; - _url_with_synthesis($medium) && "$urpm->{cachedir}/partial/" . _url_with_synthesis_basename($medium); + _url_with_synthesis($medium) && "$urpm->{cachedir}/partial/synthesis.hdlist.cz"; } sub any_synthesis { my ($urpm, $medium) = @_; @@ -1197,9 +1197,9 @@ sub _download_media_info_file { if (_synthesis_suffix($medium)) { my $local_name = $prefix . _synthesis_suffix($medium) . $suffix; - if (urpm::download::sync_rel($urpm, $medium, [_synthesis_dir_rel($medium) . "/$local_name"], - dir => $download_dir, quiet => $quiet, callback => $o_callback)) { - rename("$download_dir/$local_name", $result_file); + if (urpm::download::sync_rel_to($urpm, $medium, + _synthesis_dir_rel($medium) . "/$local_name", $result_file, + dir => $download_dir, quiet => $quiet, callback => $o_callback)) { $found = 1; } } @@ -1273,8 +1273,9 @@ sub get_synthesis__remote { my ($urpm, $medium, $is_a_probe, $options) = @_; my $ok = try__maybe_mirrorlist($urpm, $medium, $is_a_probe, sub { - urpm::download::sync_rel($urpm, $medium, [ _url_with_synthesis_rel($medium) ], - quiet => $options->{quiet}, callback => $options->{callback}) && + urpm::download::sync_rel_to($urpm, $medium, _url_with_synthesis_rel($medium), + cachedir_with_synthesis($urpm, $medium), + quiet => $options->{quiet}, callback => $options->{callback}) && _check_synthesis(cachedir_with_synthesis($urpm, $medium)); }); if (!$ok) { |