summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--urpm.pm13
-rw-r--r--urpm/get_pkgs.pm6
-rw-r--r--urpm/media.pm8
3 files changed, 15 insertions, 12 deletions
diff --git a/urpm.pm b/urpm.pm
index f0ac28f6..4982bc09 100644
--- a/urpm.pm
+++ b/urpm.pm
@@ -111,13 +111,22 @@ sub userdir {
-d $dir && ! -l $dir or $urpm->{fatal}(1, N("fail to create directory %s", $dir));
-o $dir && -w $dir or $urpm->{fatal}(1, N("invalid owner for directory %s", $dir));
- $urpm->{cachedir} = $dir;
-
mkdir "$dir/partial";
mkdir "$dir/rpms";
$dir;
}
+sub ensure_valid_cachedir {
+ my ($urpm) = @_;
+ if (my $dir = userdir($urpm)) {
+ $urpm->{cachedir} = $dir;
+ }
+ -w "$urpm->{cachedir}/partial" or $urpm->{fatal}(1, N("Can not download packages into %s", "$urpm->{cachedir}/partial"));
+}
+sub valid_cachedir {
+ my ($urpm) = @_;
+ userdir($urpm) || $urpm->{cachedir};
+}
sub is_temporary_file {
my ($urpm, $f) = @_;
diff --git a/urpm/get_pkgs.pm b/urpm/get_pkgs.pm
index b0545107..65521ac4 100644
--- a/urpm/get_pkgs.pm
+++ b/urpm/get_pkgs.pm
@@ -208,11 +208,7 @@ sub download_packages_of_distant_media {
sub _download_packages_of_distant_media {
my ($urpm, $sources, $errors, $blist, %options) = @_;
- my $cachedir = $urpm->{cachedir};
- if (! -w "$cachedir/partial") {
- $cachedir = urpm::userdir($urpm)
- or $urpm->{fatal}(1, N("Can not download packages into %s", "$cachedir/partial"));
- }
+ my $cachedir = urpm::valid_cachedir($urpm);
$urpm->{log}(N("retrieving rpm files from medium \"%s\"...", $blist->{medium}{name}));
if (urpm::download::sync_rel($urpm, $blist->{medium}, [ urpm::blist_to_filenames($blist) ],
diff --git a/urpm/media.pm b/urpm/media.pm
index 94fb7f69..fae5abb2 100644
--- a/urpm/media.pm
+++ b/urpm/media.pm
@@ -1763,12 +1763,10 @@ sub _any_media_info__or_download {
-s $f and return $f;
my $download_dir;
- if (my $userdir = urpm::userdir($urpm)) {
- $f = "$userdir/" . statedir_media_info_basename($medium, $prefix, $suffix);
+ if ($<) {
+ urpm::ensure_valid_cachedir($urpm);
+ $f = "$urpm->{cachedir}/" . statedir_media_info_basename($medium, $prefix, $suffix);
-s $f and return $f;
-
- $download_dir = "$userdir/partial";
- mkdir $download_dir;
}
get_medium_option($urpm, $medium, 'xml-info') ne 'never' or return;