From 7c16df1327b2d9e01fc27bf78aa355dd9b273a4d Mon Sep 17 00:00:00 2001 From: Pascal Rigaux Date: Fri, 22 Feb 2008 15:18:58 +0000 Subject: get_content() as a wrapper around sync() to get file content --- urpm/download.pm | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/urpm/download.pm b/urpm/download.pm index fce2bf5e..2d2ee2e1 100644 --- a/urpm/download.pm +++ b/urpm/download.pm @@ -741,6 +741,21 @@ sub sync { }; } +sub get_content { + my ($urpm, $url) = @_; + + my $file = "$urpm->{cachedir}/partial/" . basename($url); + + unlink $file; # prevent "partial file" errors + urpm::download::sync($urpm, undef, [ $url ]) or return; + + my @l = cat_($file); + unlink $file; + + wantarray ? @l : join('', @l); +} + + #- syncing algorithms. sub _sync_webfetch_raw { my ($urpm, $files, $options) = @_; -- cgit v1.2.1