Skip to content

Commit

Permalink
use the getTTL method to find the time to pause running a Workflow.
Browse files Browse the repository at this point in the history
  • Loading branch information
perlDreamer committed Sep 24, 2010
1 parent c707d70 commit dec9105
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
13 changes: 7 additions & 6 deletions lib/WebGUI/Workflow/Activity/CleanTempStorage.pm
Expand Up @@ -102,8 +102,9 @@ See WebGUI::Workflow::Activity::execute() for details.
=cut

sub execute {
my $self = shift;
my $self = shift;
my $start = time();
my $stop = $start + $self->getTTL;

# kill temporary assets
my $tempspace = WebGUI::Asset->getTempspace($self->session);
Expand All @@ -125,11 +126,11 @@ sub execute {
}
}
# taking too long, give up
return $self->WAITING(1) if (time() - $start > $self->getTTL);
return $self->WAITING(1) if (time() > $stop);
}

# kill temporary files
return $self->recurseFileSystem($start, $self->session->config->get("uploadsPath")."/temp");
return $self->recurseFileSystem($stop, $self->session->config->get("uploadsPath")."/temp");
}


Expand All @@ -147,18 +148,18 @@ The starting path.

sub recurseFileSystem {
my $self = shift;
my $start = shift;
my $stop = shift;
my $path = shift;
if (opendir(DIR,$path)) {
my @filelist = readdir(DIR);
closedir(DIR);
foreach my $file (@filelist) {
unless ($file eq "." || $file eq "..") {
# taking too long, time to abort
return $self->WAITING(1) if (time() - $start > 50);
return $self->WAITING(1) if (time() > $stop);

# must search for children
$self->recurseFileSystem($start, $path."/".$file);
$self->recurseFileSystem($stop, $path."/".$file);

# if it's old enough, let's kill it
if ($self->checkFileAge($path."/".$file)) {
Expand Down
4 changes: 2 additions & 2 deletions lib/WebGUI/Workflow/Activity/ExpirePurchasedThingyRecords.pm
Expand Up @@ -111,7 +111,7 @@ sub execute {
$msg->addHtml( $self->get('notificationMessage') );
$msg->queue;

if ( time - $time > 60 ) {
if ( time - $time > $self->getTTL ) {
return $self->WAITING(1);
}
}
Expand Down Expand Up @@ -140,7 +140,7 @@ sub execute {

$asset->deleteThingRecord( $asset->get('thingId'), $record->getId );

if ( time - $time > 60 ) {
if ( time - $time > $self->getTTL ) {
return $self->WAITING(1);
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/WebGUI/Workflow/Activity/ExtendCalendarRecurrences.pm
Expand Up @@ -65,7 +65,7 @@ See WebGUI::Workflow::Activity::execute() for details.

sub execute {
my ( $self, $obj, $instance ) = @_;
my $timeLimit = time + 55;
my $timeLimit = time + self->getTTL;

my $piped = $instance->getScratch('recurrences')
|| $self->generateRecurrenceList();
Expand Down

0 comments on commit dec9105

Please sign in to comment.