Mailing List Archive

rt branch, 4.4/clear-mason-cache-button, repushed
The branch 4.4/clear-mason-cache-button was deleted and repushed:
was 7f9a49606b1e3acaaf26013ded129a24b12ea7ad
now 7d895ac15f2577c63034f4d51f77244f8c362929

1: 7f9a49606b ! 1: 7d895ac15f Add support to clear mason cache via web interface
@@ -20,6 +20,48 @@

$HTML::Mason::Commands::r->content_type("text/html; charset=utf-8");

+@@
+ return $name ? $env->{$name} : $env;
+ }
+
++=head2 ClearMasonCache
++
++Delete current mason cache.
++
++=cut
++
++sub ClearMasonCache {
++ require File::Path;
++ require File::Spec;
++ my $mason_obj_dir = File::Spec->catdir( $RT::MasonDataDir, 'obj' );
++
++ my $error;
++
++ # There is a race condition that other processes add new cache items while
++ # remove_tree is running, which could prevent it from deleting the whole "obj"
++ # directory with errors like "Directory not empty". Let's try for a few times
++ # here to get around it.
++
++ for ( 1 .. 10 ) {
++ last unless -e $mason_obj_dir;
++ File::Path::remove_tree( $mason_obj_dir, { safe => 1, error => \$error } );
++ }
++
++ if ( $error && @$error ) {
++
++ # Only one dir is specified, so there will be only one error if any
++ my ( $file, $message ) = %{ $error->[0] };
++ RT->Logger->error("Failed to clear mason cache: $file => $message");
++ return ( 0, HTML::Mason::Commands::loc( "Failed to clear mason cache: [_1] => [_2]", $file, $message ) );
++ }
++ else {
++ return ( 1, HTML::Mason::Commands::loc('Cache cleared') );
++ }
++}
++
+ package HTML::Mason::Commands;
+
+ use vars qw/$r $m %session/;

diff --git a/share/html/Admin/Helpers/ClearMasonCache b/share/html/Admin/Helpers/ClearMasonCache
new file mode 100644
@@ -74,38 +116,10 @@
+%#
+%# END BPS TAGGED BLOCK }}}
+<%init>
-+use File::Path 'remove_tree';
-+use File::Spec;
-+my $mason_obj_dir = File::Spec->catdir( $RT::MasonDataDir, 'obj' );
+
-+my $error;
-+
-+# There is a race condition that other processes add new cache items while
-+# remove_tree is running, which could prevent it from deleting the whole "obj"
-+# directory with errors like "Directory not empty". Let's try for a few times
-+# here to get around it.
-+
-+for ( 1 .. 10 ) {
-+ last unless -e $mason_obj_dir;
-+ remove_tree( $mason_obj_dir, { safe => 1, error => \$error } );
-+}
-+
-+my %ret;
-+if ( $error && @$error ) {
-+ $ret{status} = 'error';
-+
-+ # Only one dir is specified, so there will be only one error if any
-+ my ( $file, $message ) = %{ $error->[ 0 ] };
-+ RT->Logger->error( "Failed to clear mason cache: $file => $message" );
-+ $ret{message} = loc( "Failed to clear mason cache: [_1] => [_2]", $file, $message );
-+}
-+else {
-+ $ret{status} = 'success';
-+ $ret{message} = loc( 'Cache cleared' );
-+}
-+
++my ( $ret, $msg ) = RT::Interface::Web::ClearMasonCache();
+$r->content_type( 'application/json; charset=utf-8' );
-+$m->out( JSON( \%ret ) );
++$m->out( JSON( { status => $ret, message => $msg } ) );
+$m->abort;
+</%init>

@@ -144,8 +158,8 @@
--- a/share/static/css/base/admin.css
+++ b/share/static/css/base/admin.css
@@
- table.upgrade-history .upgrade-history-parent .widget a.rolled-up {
- background-image: url(../../../static/images/css/rolldown-arrow.gif);
+ text-align: left;
+ width: 85%;
}
+
+div.mason-cache {

_______________________________________________
rt-commit mailing list
rt-commit@lists.bestpractical.com
http://lists.bestpractical.com/cgi-bin/mailman/listinfo/rt-commit