[vhffs-dev] [2082] reworked cleanup robots

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


Revision: 2082
Author:   gradator
Date:     2012-02-29 21:45:23 +0100 (Wed, 29 Feb 2012)
Log Message:
-----------
reworked cleanup robots

Modified Paths:
--------------
    trunk/vhffs-robots/src/object_cleanup.pl
    trunk/vhffs-robots/src/user_cleanup.pl

Modified: trunk/vhffs-robots/src/object_cleanup.pl
===================================================================
--- trunk/vhffs-robots/src/object_cleanup.pl	2012-02-29 20:32:32 UTC (rev 2081)
+++ trunk/vhffs-robots/src/object_cleanup.pl	2012-02-29 20:45:23 UTC (rev 2082)
@@ -1,5 +1,4 @@
 #!%PERL%
-
 # Copyright (c) vhffs project and its contributors
 # All rights reserved.
 #
@@ -34,25 +33,19 @@
 use utf8;
 
 use lib '%VHFFS_LIB_DIR%';
-use Vhffs::Main;
 use Vhffs::Robots;
 use Vhffs::Object;
-use Vhffs::ObjectFactory;
-use Vhffs::Constants;
 
 my $vhffs = init Vhffs::Main;
-exit 1 unless $vhffs;
+exit 1 unless defined $vhffs;
 
-Vhffs::Robots::lock( $vhffs , 'object' );
+Vhffs::Robots::lock( $vhffs, 'object' );
 
 my $objects = Vhffs::Object::getall( $vhffs , undef, Vhffs::Constants::VALIDATION_REFUSED , 1296000 );   # 15 days
-foreach my $object ( @{$objects} )
-{
-	$object = Vhffs::ObjectFactory::fetch_object( $vhffs , $object->get_oid );
-	Vhffs::Robots::vhffs_log( $vhffs, sprintf( "deleted object %d because it waited too long in refused state" , $object->get_oid ) );
-	$object->delete_withmail;
+foreach ( @{$objects} ) {
+	Vhffs::Robots::vhffs_log( $vhffs, 'Deleted object '.$_->get_oid.' because it waited too much time in refused state' );
+	$_->delete_withmail;
 }
 
-Vhffs::Robots::unlock( $vhffs , 'object' );
-
+Vhffs::Robots::unlock( $vhffs, 'object' );
 exit 0;

Modified: trunk/vhffs-robots/src/user_cleanup.pl
===================================================================
--- trunk/vhffs-robots/src/user_cleanup.pl	2012-02-29 20:32:32 UTC (rev 2081)
+++ trunk/vhffs-robots/src/user_cleanup.pl	2012-02-29 20:45:23 UTC (rev 2082)
@@ -34,23 +34,19 @@
 use utf8;
 
 use lib '%VHFFS_LIB_DIR%';
-use Vhffs::Main;
 use Vhffs::Robots;
 use Vhffs::User;
-use Vhffs::Constants;
 
 my $vhffs = init Vhffs::Main;
-exit 1 unless $vhffs;
+exit 1 unless defined $vhffs;
 
-Vhffs::Robots::lock( $vhffs , 'usergroup' );
+Vhffs::Robots::lock( $vhffs, 'user' );
 
 my $users = Vhffs::User::get_unused_accounts( $vhffs , 2592000 );   # 30 days
-foreach my $user ( @{$users} )
-{
-	Vhffs::Robots::vhffs_log( $vhffs, sprintf( 'deleted user %s because it was unused' , $user->get_username ) , $vhffs );
-	$user->pendingdeletion_withmail;
+foreach ( @{$users} ) {
+	Vhffs::Robots::vhffs_log( $vhffs, 'Deleted user '.$_->get_username.' because it was unused' );
+	$_->pendingdeletion_withmail;
 }
 
-Vhffs::Robots::unlock( $vhffs , 'usergroup' );
-
+Vhffs::Robots::unlock( $vhffs, 'user' );
 exit 0;


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