fu: Close-up of Fu, bringing a scoop of water to her mouth (Default)
fu ([personal profile] fu) wrote in [site community profile] changelog2010-09-23 08:43 am

[dw-free] Style browser doesn't update with new styles immediately after update-db is run

[commit: http://hg.dwscoalition.org/dw-free/rev/546822cdaab6]

http://bugs.dwscoalition.org/show_bug.cgi?id=3076

Clear cache on dev servers (the clearing cache part is within an if-
statement)

Patch by [personal profile] fu.

Files modified:
  • bin/upgrading/update-db.pl
--------------------------------------------------------------------------------
diff -r 4bfe60fcdd15 -r 546822cdaab6 bin/upgrading/update-db.pl
--- a/bin/upgrading/update-db.pl	Wed Sep 22 16:19:10 2010 +0800
+++ b/bin/upgrading/update-db.pl	Thu Sep 23 16:40:17 2010 +0800
@@ -271,6 +271,7 @@ sub populate_s2 {
         chdir "$ENV{'LJHOME'}/bin/upgrading" or die;
         my %layer;    # maps redist_uniq -> { 'type', 'parent' (uniq), 'id' (s2lid) }
 
+        my $has_new_layer = 0;
         my $compile = sub {
             my ($base, $type, $parent, $s2source) = @_;
             return unless $s2source =~ /\S/;
@@ -306,6 +307,8 @@ sub populate_s2 {
             my $md5_source = Digest::MD5::md5_hex($s2source);
             my $source_exist = LJ::S2::load_layer_source($id);
             my $md5_exist = Digest::MD5::md5_hex($source_exist);
+
+            $has_new_layer = 1 unless $source_exist;
 
             # skip compilation if source is unchanged and parent wasn't rebuilt.
             return if $md5_source eq $md5_exist && ! $layer{$parent}->{'built'} && ! $opt_forcebuild;
@@ -437,6 +440,13 @@ sub populate_s2 {
             } else {
                 print "\nOkay, I am NOT deleting the layers.\n";
             }
+        }
+
+        if ( $has_new_layer ) {
+            $LJ::CACHED_PUBLIC_LAYERS = undef;
+            LJ::MemCache::delete( "s2publayers" );
+
+            print "\nCleared styles cache.\n";
         }
     }
 
--------------------------------------------------------------------------------