Remove cookie jar files left by the HttpProxy asset. Finishes the fix for bug #12327.
This commit is contained in:
parent
604887ff66
commit
07bd545538
4 changed files with 130 additions and 0 deletions
|
|
@ -31,10 +31,26 @@ my $quiet; # this line required
|
|||
my $session = start(); # this line required
|
||||
|
||||
# upgrade functions go here
|
||||
installCleanCookieJars($session);
|
||||
|
||||
finish($session); # this line required
|
||||
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Describe what our function does
|
||||
sub installCleanCookieJars {
|
||||
my $session = shift;
|
||||
print "\tInstall the new CleanCookieJars workflow activity... " unless $quiet;
|
||||
# and here's our code
|
||||
$session->config->addToArray('workflowActivities/None', 'WebGUI::Workflow::Activity::CleanCookieJars');
|
||||
my $workflow = WebGUI::Workflow->new($session, 'pbworkflow000000000001');
|
||||
my $cleaner = $workflow->addActivity('WebGUI::Workflow::Activity::CleanCookieJars');
|
||||
$cleaner->set('title', 'Clean HttpProxy Cookie jars');
|
||||
$cleaner->set('description', 'Removes cookie jar files from the HttpProxy asset that are older than 1 day');
|
||||
print "DONE!\n" unless $quiet;
|
||||
}
|
||||
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Describe what our function does
|
||||
#sub exampleFunction {
|
||||
|
|
|
|||
|
|
@ -897,6 +897,7 @@
|
|||
"WebGUI::Workflow::Activity::ArchiveOldStories",
|
||||
"WebGUI::Workflow::Activity::ArchiveOldThreads",
|
||||
"WebGUI::Workflow::Activity::CalendarUpdateFeeds",
|
||||
"WebGUI::Workflow::Activity::CleanCookieJars",
|
||||
"WebGUI::Workflow::Activity::CleanDatabaseCache",
|
||||
"WebGUI::Workflow::Activity::CleanFileCache",
|
||||
"WebGUI::Workflow::Activity::CleanLoginHistory",
|
||||
|
|
|
|||
101
lib/WebGUI/Workflow/Activity/CleanCookieJars.pm
Normal file
101
lib/WebGUI/Workflow/Activity/CleanCookieJars.pm
Normal file
|
|
@ -0,0 +1,101 @@
|
|||
package WebGUI::Workflow::Activity::CleanCookieJars;
|
||||
|
||||
|
||||
=head1 LEGAL
|
||||
|
||||
-------------------------------------------------------------------
|
||||
WebGUI is Copyright 2001-2012 Plain Black Corporation.
|
||||
-------------------------------------------------------------------
|
||||
Please read the legal notices (docs/legal.txt) and the license
|
||||
(docs/license.txt) that came with this distribution before using
|
||||
this software.
|
||||
-------------------------------------------------------------------
|
||||
http://www.plainblack.com info@plainblack.com
|
||||
-------------------------------------------------------------------
|
||||
|
||||
=cut
|
||||
|
||||
use strict;
|
||||
use base 'WebGUI::Workflow::Activity';
|
||||
use WebGUI::International;
|
||||
use WebGUI::Storage;
|
||||
use File::Basename ();
|
||||
use File::Spec;
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Package WebGUI::Workflow::Activity::CleanCookieJars
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
Cleans up stale cookie jars
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
See WebGUI::Workflow::Activity for details on how to use any activity.
|
||||
|
||||
=head1 METHODS
|
||||
|
||||
These methods are available from this class:
|
||||
|
||||
=cut
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 definition ( session, definition )
|
||||
|
||||
See WebGUI::Workflow::Activity::defintion() for details.
|
||||
|
||||
=cut
|
||||
|
||||
sub definition {
|
||||
my $class = shift;
|
||||
my $session = shift;
|
||||
my $definition = shift;
|
||||
my $i18n = WebGUI::International->new( $session, "Workflow_Activity_CleanCookieJars" );
|
||||
push(@{$definition}, {
|
||||
name => $i18n->get("activity cleanup cookie jars"),
|
||||
properties => {}
|
||||
});
|
||||
return $class->SUPER::definition($session,$definition);
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 execute ( )
|
||||
|
||||
See WebGUI::Workflow::Activity::execute() for details.
|
||||
|
||||
=cut
|
||||
|
||||
sub execute {
|
||||
my $self = shift;
|
||||
my $session = $self->session;
|
||||
# keep track of how much time it's taking
|
||||
my $stop_time = time + $self->getTTL;
|
||||
|
||||
my $get_proxy = $session->db->read('select assetId, revisionDate, cookieJarStorageId from HttpProxy');
|
||||
STORAGEID: while (1) {
|
||||
my ($assetId, $revisionDate, $storageId,) = $get_proxy->array();
|
||||
last STORAGEID unless $storageId;
|
||||
my $storage = WebGUI::Storage->get($session, $storageId);
|
||||
next unless $storage;
|
||||
opendir my $directory, $storage->getPath;
|
||||
FILE: while (my $file = readdir($directory)) {
|
||||
next FILE if $file =~ /^\./;
|
||||
my $whole_file = $storage->getPath($file);
|
||||
if (-M $whole_file >=1) {
|
||||
unlink $whole_file;
|
||||
}
|
||||
last STORAGEID if time > $stop_time;
|
||||
}
|
||||
}
|
||||
return $self->WAITING(1) if time > $stop_time;
|
||||
return $self->COMPLETE;
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
|
||||
12
lib/WebGUI/i18n/English/Workflow_Activity_CleanCookieJars.pm
Normal file
12
lib/WebGUI/i18n/English/Workflow_Activity_CleanCookieJars.pm
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
package WebGUI::i18n::English::Workflow_Activity_CleanCookieJars;
|
||||
use strict;
|
||||
|
||||
our $I18N = {
|
||||
'activity cleanup cookie jars' => {
|
||||
message => q|Clean Stale Cookie-Jar Files|,
|
||||
context => q|The name of this workflow activity.|,
|
||||
lastUpdated => 0,
|
||||
},
|
||||
};
|
||||
|
||||
1;
|
||||
Loading…
Add table
Add a link
Reference in a new issue