[vhffs-dev] [2029] replaced all system("rm -rf") like to File::Path::rmtree |
[ Thread Index |
Date Index
| More vhffs.org/vhffs-dev Archives
]
Revision: 2029
Author: gradator
Date: 2012-02-19 21:08:55 +0100 (Sun, 19 Feb 2012)
Log Message:
-----------
replaced all system("rm -rf") like to File::Path::rmtree
Modified Paths:
--------------
trunk/vhffs-api/src/Vhffs/Robots/Bazaar.pm
trunk/vhffs-api/src/Vhffs/Robots/Cvs.pm
trunk/vhffs-api/src/Vhffs/Robots/Git.pm
trunk/vhffs-api/src/Vhffs/Robots/Group.pm
trunk/vhffs-api/src/Vhffs/Robots/Mercurial.pm
trunk/vhffs-api/src/Vhffs/Robots/Repository.pm
trunk/vhffs-api/src/Vhffs/Robots/Svn.pm
trunk/vhffs-api/src/Vhffs/Robots/User.pm
trunk/vhffs-api/src/Vhffs/Robots/Web.pm
trunk/vhffs-intl/update-POTFILES.in.pl
trunk/vhffs-robots/src/mail_delete.pl
trunk/vhffs-robots/src/mail_deleteboxes.pl
Modified: trunk/vhffs-api/src/Vhffs/Robots/Bazaar.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Robots/Bazaar.pm 2012-02-19 19:22:57 UTC (rev 2028)
+++ trunk/vhffs-api/src/Vhffs/Robots/Bazaar.pm 2012-02-19 20:08:55 UTC (rev 2029)
@@ -102,7 +102,7 @@
Vhffs::Robots::archive_targz( $bazaar, $dir );
File::Path::rmtree($dir) if(-d $dir);
- my $groupdir = dirname($dir);
+ my $groupdir = File::Basename::dirname($dir);
rmdir($groupdir);
return 0;
Modified: trunk/vhffs-api/src/Vhffs/Robots/Cvs.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Robots/Cvs.pm 2012-02-19 19:22:57 UTC (rev 2028)
+++ trunk/vhffs-api/src/Vhffs/Robots/Cvs.pm 2012-02-19 20:08:55 UTC (rev 2029)
@@ -90,7 +90,7 @@
File::Path::rmtree($dir) if(-d $dir);
# Remove parent dir if empty (i.e. this group has no move CVSes).
- my $groupdir = dirname($dir);
+ my $groupdir = File::Basename::dirname($dir);
rmdir $groupdir;
return 0;
Modified: trunk/vhffs-api/src/Vhffs/Robots/Git.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Robots/Git.pm 2012-02-19 19:22:57 UTC (rev 2028)
+++ trunk/vhffs-api/src/Vhffs/Robots/Git.pm 2012-02-19 20:08:55 UTC (rev 2029)
@@ -118,7 +118,7 @@
Vhffs::Robots::archive_targz( $git, $dir );
File::Path::rmtree($dir) if(-d $dir);
- my $groupdir = dirname($dir);
+ my $groupdir = File::Basename::dirname($dir);
rmdir($groupdir);
return 0;
Modified: trunk/vhffs-api/src/Vhffs/Robots/Group.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Robots/Group.pm 2012-02-19 19:22:57 UTC (rev 2028)
+++ trunk/vhffs-api/src/Vhffs/Robots/Group.pm 2012-02-19 20:08:55 UTC (rev 2029)
@@ -31,6 +31,8 @@
use strict;
use utf8;
+use File::Path;
+use File::Basename;
package Vhffs::Robots::Group;
@@ -60,7 +62,6 @@
}
-# TODO : remove system()
sub delete_groupdir
{
my $main = shift;
@@ -72,8 +73,18 @@
if( -d $dir )
{
Vhffs::Robots::archive_targz( $group, $dir );
- my $cmd = "rm -rf $dir";
- system( $cmd );
+
+ my $errors=[];
+ File::Path::rmtree( $dir, { error => \$errors });
+ # Group directories are hashed on two levels, so we've potentially two empty directories to delete
+ $dir = File::Basename::dirname($dir);
+ rmdir $dir;
+ $dir = File::Basename::dirname($dir);
+ rmdir $dir;
+
+ if(@$errors) {
+ Vhffs::Robots::vhffs_log( sprintf( 'Something went wrong during %s group deletion: %s', $group->get_groupname, join(', ', @$errors) ) );
+ }
}
return 0;
}
Modified: trunk/vhffs-api/src/Vhffs/Robots/Mercurial.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Robots/Mercurial.pm 2012-02-19 19:22:57 UTC (rev 2028)
+++ trunk/vhffs-api/src/Vhffs/Robots/Mercurial.pm 2012-02-19 20:08:55 UTC (rev 2029)
@@ -144,7 +144,7 @@
Vhffs::Robots::archive_targz( $mercurial, $dir );
File::Path::rmtree($dir) if(-d $dir);
- my $groupdir = dirname($dir);
+ my $groupdir = File::Basename::dirname($dir);
rmdir($groupdir);
return 0;
Modified: trunk/vhffs-api/src/Vhffs/Robots/Repository.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Robots/Repository.pm 2012-02-19 19:22:57 UTC (rev 2028)
+++ trunk/vhffs-api/src/Vhffs/Robots/Repository.pm 2012-02-19 20:08:55 UTC (rev 2029)
@@ -38,6 +38,7 @@
use Vhffs::Constants;
use Vhffs::Functions;
use Vhffs::Group;
+use File::Path;
sub create_repository
@@ -67,13 +68,14 @@
if( defined $repo )
{
my $vhffs = $repo->{'main'};
- my $dir = $repo->get_dir;
- Vhffs::Robots::archive_targz( $repo, $dir );
+ Vhffs::Robots::archive_targz( $repo, $repo->get_dir );
- # erase all files
- my $cmd = "rm -rf $dir";
- system( $cmd );
+ my $errors=[];
+ File::Path::rmtree( $repo->get_dir, { error => \$errors });
+ if(@$errors) {
+ Vhffs::Robots::vhffs_log( sprintf( 'Something went wrong during %s download repository deletion: %s', $repo->get_name, join(', ', @$errors) ) );
+ }
# remove the link in group directory
my $group = Vhffs::Group::get_by_gid( $vhffs , $repo->get_owner_gid );
Modified: trunk/vhffs-api/src/Vhffs/Robots/Svn.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Robots/Svn.pm 2012-02-19 19:22:57 UTC (rev 2028)
+++ trunk/vhffs-api/src/Vhffs/Robots/Svn.pm 2012-02-19 20:08:55 UTC (rev 2029)
@@ -173,7 +173,7 @@
Vhffs::Robots::archive_targz( $svn, $dir );
File::Path::rmtree($dir);
- my $group_dir = dirname($dir);
+ my $group_dir = File::Basename::dirname($dir);
rmdir $group_dir;
return 0;
Modified: trunk/vhffs-api/src/Vhffs/Robots/User.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Robots/User.pm 2012-02-19 19:22:57 UTC (rev 2028)
+++ trunk/vhffs-api/src/Vhffs/Robots/User.pm 2012-02-19 20:08:55 UTC (rev 2029)
@@ -69,8 +69,17 @@
{
Vhffs::Robots::archive_targz( $user, $homedir );
- $cmd = "rm -rf $homedir";
- system( $cmd );
+ my $errors=[];
+ File::Path::rmtree( $homedir, { error => \$errors });
+ # Home directories are hashed on two levels, so we've potentially two empty directories to delete
+ $homedir = File::Basename::dirname($homedir);
+ rmdir $homedir;
+ $homedir = File::Basename::dirname($homedir);
+ rmdir $homedir;
+
+ if(@$errors) {
+ Vhffs::Robots::vhffs_log( sprintf( 'Something went wrong during %s home deletion: %s', $user->get_username, join(', ', @$errors) ) );
+ }
}
}
Modified: trunk/vhffs-api/src/Vhffs/Robots/Web.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Robots/Web.pm 2012-02-19 19:22:57 UTC (rev 2028)
+++ trunk/vhffs-api/src/Vhffs/Robots/Web.pm 2012-02-19 20:08:55 UTC (rev 2029)
@@ -102,11 +102,11 @@
Vhffs::Robots::archive_targz( $web, $webdir );
File::Path::rmtree( $webdir );
- my $parent = dirname($webdir);
+ my $parent = File::Basename::dirname($webdir);
rmdir $parent;
- $parent = dirname($parent);
+ $parent = File::Basename::dirname($parent);
rmdir $parent;
- $parent = dirname($parent);
+ $parent = File::Basename::dirname($parent);
rmdir $parent;
$web->add_history( "Webdir is now erased.");
Modified: trunk/vhffs-intl/update-POTFILES.in.pl
===================================================================
--- trunk/vhffs-intl/update-POTFILES.in.pl 2012-02-19 19:22:57 UTC (rev 2028)
+++ trunk/vhffs-intl/update-POTFILES.in.pl 2012-02-19 20:08:55 UTC (rev 2029)
@@ -15,7 +15,7 @@
use File::Spec;
my $script = File::Spec->rel2abs(__FILE__);
-my $src_root = dirname(dirname($script));
+my $src_root = File::Basename::dirname(dirname($script));
my @src_subdirs = qw/vhffs-contrib vhffs-panel vhffs-listengine
vhffs-tools vhffs-mw vhffs-api vhffs-shells vhffs-public
vhffs-jabber vhffs-irc vhffs-stsmon vhffs-intl/;
Modified: trunk/vhffs-robots/src/mail_delete.pl
===================================================================
--- trunk/vhffs-robots/src/mail_delete.pl 2012-02-19 19:22:57 UTC (rev 2028)
+++ trunk/vhffs-robots/src/mail_delete.pl 2012-02-19 20:08:55 UTC (rev 2029)
@@ -31,6 +31,8 @@
use strict;
use utf8;
+use File::Path;
+use File::Basename;
use lib '%VHFFS_LIB_DIR%';
@@ -38,8 +40,6 @@
use Vhffs::Services::MailingList;
use Vhffs::Robots;
use Vhffs::Main;
-use File::Path;
-use File::Basename;
my $vhffs = init Vhffs::Main;
@@ -79,13 +79,12 @@
my $dir = $mail->get_dir;
my $errors=[];
File::Path::rmtree( $mail->get_dir, { error => \$errors });
- # Mail domain directories are hashed on two levels, so we've 3 potentially
- # empty directories to delete
- $dir = dirname($dir);
+ # Mail domain directories are hashed on two levels, so we've potentially two empty directories to delete
+ $dir = File::Basename::dirname($dir);
rmdir $dir;
- $dir = dirname($dir);
+ $dir = File::Basename::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 2012-02-19 19:22:57 UTC (rev 2028)
+++ trunk/vhffs-robots/src/mail_deleteboxes.pl 2012-02-19 20:08:55 UTC (rev 2029)
@@ -60,7 +60,7 @@
if( -d $dir ) {
File::Path::rmtree($dir);
# Remove the letter/ directory if empty
- rmdir dirname($dir);
+ rmdir File::Basename::dirname($dir);
}
$mail->delbox( $b->{local_part} );
}