Make PurgeOldTrash respect the workflow activity TTL.

This commit is contained in:
Colin Kuskie 2010-02-22 20:46:44 -08:00
parent 8d4a63b774
commit 29b0d490b9

View file

@ -75,13 +75,21 @@ See WebGUI::Workflow::Activity::execute() for details.
=cut
sub execute {
my $self = shift;
my $sth = $self->session->db->read("select assetId,className from asset where state='trash' and stateChanged < ?", [time() - $self->get("purgeAfter")]);
while (my ($id, $class) = $sth->array) {
my $asset = WebGUI::Asset->new($self->session, $id,$class);
$asset->purge if (defined $asset);
my $self = shift;
my $sth = $self->session->db->read( "select assetId,className from asset where state='trash' and stateChanged < ? order by stateChanged ASC",
[ time() - $self->get("purgeAfter") ]
);
my $expireTime = time() + $self->getTTL();
while ( my ( $id, $class ) = $sth->array ) {
my $asset = WebGUI::Asset->new( $self->session, $id, $class );
$asset->purge if ( defined $asset );
if (time() > $expireTime) {
$sth->finish;
return $self->WAITING(1);
}
return $self->COMPLETE;
}
$sth->finish;
return $self->COMPLETE;
}