File mirror-directories-deleted.patch of Package mirror.9822
Index: mirror.pl
===================================================================
--- mirror.pl.orig
+++ mirror.pl
@@ -3179,9 +3179,12 @@ sub do_delete
$del =~ s,/+$,,;
if( $do_deletes ){
if( $get_file ){
- &msg( $log, "rmdir $cwd/$del\n" );
- rmdir( "$cwd/$del" ) ||
- &msg( $log, "rmdir $cwd/$del failed: $!\n" );
+ # bsc#1117110, delete empty dir only
+ if( is_folder_empty("$cwd/$del") ){
+ &msg( $log, "rmdir $cwd/$del\n" );
+ rmdir( "$cwd/$del" ) ||
+ &msg( $log, "rmdir $cwd/$del failed: $!\n" );
+ }
}
else {
&msg( $log, "delete DIR $del\n" );
@@ -3223,6 +3226,13 @@ sub do_delete
}
}
+sub is_folder_empty
+{
+ my $dirname = shift;
+ opendir(my $dh, $dirname) or die "Not a directory";
+ return scalar(grep { $_ ne "." && $_ ne ".." } readdir($dh)) == 0;
+}
+
sub filesize
{
local( $fname ) = @_;