From 4a8e726b2a297aa91642afb2abd60844a8b63bff Mon Sep 17 00:00:00 2001 From: Thierry Vignaud Date: Thu, 13 Dec 2012 09:54:08 +0000 Subject: (write_ldap_cache) simplify using output_safe() --- urpm/ldap.pm | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'urpm/ldap.pm') diff --git a/urpm/ldap.pm b/urpm/ldap.pm index 5c5edbb3..281ad56c 100644 --- a/urpm/ldap.pm +++ b/urpm/ldap.pm @@ -40,14 +40,12 @@ sub write_ldap_cache($$) { # FIXME what perm for cache ? -d $ldap_cache or mkdir $ldap_cache or die N("Cannot create ldap cache directory"); - open my $cache, ">", "$ldap_cache/$medium->{name}" - or die N("Cannot write cache file for ldap\n"); - print $cache "# internal cache file for disconnect ldap operation, do not edit\n"; - foreach (keys %$medium) { - defined $medium->{$_} or next; - print $cache "$_ = $medium->{$_}\n"; - } - close $cache; + output_safe("$ldap_cache/$medium->{name}", + join("\n", + "# internal cache file for disconnect ldap operation, do not edit", + map { "$_ = $medium->{$_}" } grep { $medium->{$_} } keys %$medium + ) + ) or die N("Cannot write cache file for ldap\n"); return 1; } -- cgit v1.2.1