[vhffs-dev] [1428] Fixes #0000262 on Webareas

[ Thread Index | Date Index | More vhffs.org/vhffs-dev Archives ]


Revision: 1428
Author:   beuss
Date:     2009-06-03 17:23:40 +0200 (Wed, 03 Jun 2009)

Log Message:
-----------
Fixes #0000262 on Webareas

Modified Paths:
--------------
    trunk/vhffs-api/src/Vhffs/Robots/Web.pm
    trunk/vhffs-robots/src/mail_delete.pl
    trunk/vhffs-robots/src/mail_deleteboxes.pl


Modified: trunk/vhffs-api/src/Vhffs/Robots/Web.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Robots/Web.pm	2009-06-03 12:26:37 UTC (rev 1427)
+++ trunk/vhffs-api/src/Vhffs/Robots/Web.pm	2009-06-03 15:23:40 UTC (rev 1428)
@@ -82,12 +82,11 @@
 sub delete
 {
 	use Vhffs::Group;
+	use File::Path;
+	use File::Basename;
 
-	my( $main , $web );
-	$main = shift;
-	$web = shift;
+	my( $main , $web ) = @_;
 
-
 	my $dir;	
 	if(defined $web)
 	{
@@ -108,7 +107,13 @@
 			$web->add_history( "Webdir is now unlinked from the group directory");
 		}
 
-        system("rm -rf '$webdir' 2> /dev/null");
+		File::Path::rmtree( $webdir );
+		my $parent = dirname($webdir);
+		rmdir $parent;
+		$parent = dirname($parent);
+		rmdir $parent;
+		$parent = dirname($parent);
+		rmdir $parent;
 
 		$web->add_history( "Webdir is now erased.");
 		$web->delete;	

Modified: trunk/vhffs-robots/src/mail_delete.pl
===================================================================
--- trunk/vhffs-robots/src/mail_delete.pl	2009-06-03 12:26:37 UTC (rev 1427)
+++ trunk/vhffs-robots/src/mail_delete.pl	2009-06-03 15:23:40 UTC (rev 1428)
@@ -39,6 +39,7 @@
 use Vhffs::Robots;
 use Vhffs::Main;
 use File::Path;
+use File::Basename;
 
 
 my $vhffs = init Vhffs::Main;
@@ -73,7 +74,15 @@
 
 	Vhffs::Robots::vhffs_log( sprintf( "Delete mail domain %s" , $mail->get_domain ) , $vhffs);
 	if( $mail->get_dir && -d -r -w -x $mail->get_dir )  {
+		my $dir = $mail->get_dir;
 		File::Path::rmtree( $mail->get_dir, { error => \my $errors });
+		# Mail domain directories are hashed on two levels, so we've 3 potentially
+		# empty directories to delete
+		$dir = dirname($dir);
+		rmdir $dir;
+		$dir = dirname($dir);
+		rmdir $dir;
+		
 		if(@$errors) {
 			Vhffs::Robots::vhffs_log( sprintf( 'Something went wrong during %s mail domain deletion: %s', $mail->get_domain, join(', ', @$errors) ) );
 		}

Modified: trunk/vhffs-robots/src/mail_deleteboxes.pl
===================================================================
--- trunk/vhffs-robots/src/mail_deleteboxes.pl	2009-06-03 12:26:37 UTC (rev 1427)
+++ trunk/vhffs-robots/src/mail_deleteboxes.pl	2009-06-03 15:23:40 UTC (rev 1428)
@@ -38,6 +38,8 @@
 use Vhffs::Robots::Mail;
 use Vhffs::Robots;
 use Vhffs::Main;
+use File::Path;
+use File::Basename;
 
 my $vhffs = init Vhffs::Main;
 die('Unable to initialize VHFFS main object') unless defined $vhffs;
@@ -59,8 +61,9 @@
 					my $cmd = 'tar cf '.$mailconf->{'archives_dir'}.'/'.time().'_'.$b->{local_part}.'@'.$b->{domain}.'.tar . 1> /dev/null 2> /dev/null';
 					system( $cmd );
 				}
-				my $cmd = 'rm -rf '.$dir.' 2> /dev/null';
-				system( $cmd );
+				File::Path::rmtree($dir);
+				# Remove the letter/ directory if empty
+				rmdir dirname($dir);
 			}
 		}
 		$mail->delbox( $b->{local_part} );


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/