[vhffs-dev] [1424] No more double deletion failure when deleting mail domain with existing boxes and mailing lists (#0000263) |
[ Thread Index |
Date Index
| More vhffs.org/vhffs-dev Archives
]
- To: vhffs-dev@xxxxxxxxx
- Subject: [vhffs-dev] [1424] No more double deletion failure when deleting mail domain with existing boxes and mailing lists (#0000263)
- From: subversion@xxxxxxxxxxxxx
- Date: Wed, 03 Jun 2009 07:43:33 +0200
Revision: 1424
Author: beuss
Date: 2009-06-03 07:43:32 +0200 (Wed, 03 Jun 2009)
Log Message:
-----------
No more double deletion failure when deleting mail domain with existing boxes and mailing lists (#0000263)
Modified Paths:
--------------
trunk/vhffs-robots/src/mail_delete.pl
Modified: trunk/vhffs-robots/src/mail_delete.pl
===================================================================
--- trunk/vhffs-robots/src/mail_delete.pl 2009-05-30 16:50:09 UTC (rev 1423)
+++ trunk/vhffs-robots/src/mail_delete.pl 2009-06-03 05:43:32 UTC (rev 1424)
@@ -38,9 +38,9 @@
use Vhffs::Services::MailingList;
use Vhffs::Robots;
use Vhffs::Main;
+use File::Path;
-
my $vhffs = init Vhffs::Main;
Vhffs::Robots::lock( $vhffs , "mail" );
@@ -58,19 +58,29 @@
$list->commit;
}
Vhffs::Robots::vhffs_log( sprintf( 'Cannot delete mail domain %s, remains lists, requests have been sent to delete them' , $mail->get_domain ) , $vhffs);
- } elsif( $mail->nb_boxes() > 0 ) {
+ # Do not call next right now, check for boxes to avoir further failure
+ }
+
+ if( $mail->nb_boxes() > 0 ) {
foreach my $bo ( values( %{$mail->get_boxes()} ) ) {
$mail->set_box_status( $bo->{'local_part'} , Vhffs::Constants::TO_DELETE );
}
Vhffs::Robots::vhffs_log( sprintf( 'Cannot delete mail domain %s, remains %d boxes, requests have been sent to delete them' , $mail->get_domain , $mail->nb_boxes() ) , $vhffs);
+ next;
+ }
+
+ next if(@$lists);
+
+ Vhffs::Robots::vhffs_log( sprintf( "Delete mail domain %s" , $mail->get_domain ) , $vhffs);
+ if( $mail->get_dir && -d -r -w -x $mail->get_dir ) {
+ File::Path::rmtree( $mail->get_dir, { error => \my $errors });
+ if(@$errors) {
+ Vhffs::Robots::vhffs_log( sprintf( 'Something went wrong during %s mail domain deletion: %s', $mail->get_domain, join(', ', @$errors) ) );
+ }
} else {
- Vhffs::Robots::vhffs_log( sprintf( "Delete mail domain %s" , $mail->get_domain ) , $vhffs);
- if( $mail->get_dir && -d $mail->get_dir && chdir( $mail->get_dir ) ) {
- my $cmd = 'rm -r '.$mail->get_dir;
- system( $cmd );
- }
- $mail->delete;
+ Vhffs::Robots::vhffs_log( sprintf( 'Unable to get mail domain directory or bad permission for mail domain %s, aborting file system deletion', $mail->get_domain ) );
}
+ $mail->delete;
}
Vhffs::Robots::unlock( $vhffs , "mail" );