[Rt-commit] rt branch 5.0/fix-clear-mason-cache updated. rt-5.0.2-27-gf578472025

BPS Git Server git at git.bestpractical.com
Fri Oct 1 20:11:52 UTC 2021


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "rt".

The branch, 5.0/fix-clear-mason-cache has been updated
       via  f578472025c9c65f40a74b497256263a64f5ed49 (commit)
      from  7f94cac59fbb457806075de35eca302d420d9a76 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit f578472025c9c65f40a74b497256263a64f5ed49
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Sat Oct 2 03:50:06 2021 +0800

    Use mason's remove_object_files instead of implementing it ourselves
    
    This is to simplify our code.

diff --git a/lib/RT/Interface/Web.pm b/lib/RT/Interface/Web.pm
index c1fb39fab2..9bc3e27faf 100644
--- a/lib/RT/Interface/Web.pm
+++ b/lib/RT/Interface/Web.pm
@@ -1967,41 +1967,6 @@ sub ClientIsIE {
     return RequestENV('HTTP_USER_AGENT') =~ m{MSIE|Trident/} ? 1 : 0;
 }
 
-=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
index 837ac4d15e..85c3a61aa9 100644
--- a/share/html/Admin/Helpers/ClearMasonCache
+++ b/share/html/Admin/Helpers/ClearMasonCache
@@ -47,8 +47,8 @@
 %# END BPS TAGGED BLOCK }}}
 <%init>
 
-my ( $ret, $msg ) = RT::Interface::Web::ClearMasonCache();
+$m->interp->remove_object_files;
 $r->content_type( 'application/json; charset=utf-8' );
-$m->out( JSON( { status => $ret, message => $msg } ) );
+$m->out( JSON( { status => 1, message => loc('Cache cleared') } ) );
 $m->abort;
 </%init>

-----------------------------------------------------------------------

Summary of changes:
 lib/RT/Interface/Web.pm                  | 35 --------------------------------
 share/html/Admin/Helpers/ClearMasonCache |  4 ++--
 2 files changed, 2 insertions(+), 37 deletions(-)


hooks/post-receive
-- 
rt


More information about the rt-commit mailing list