You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@whimsical.apache.org by ru...@apache.org on 2017/09/23 20:01:31 UTC

[whimsy] 02/03: flush cache of agendas parsed with previous versions of the library

This is an automated email from the ASF dual-hosted git repository.

rubys pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/whimsy.git

commit f79f027359218b3fe5e101dc908534004b232ed4
Author: Sam Ruby <ru...@intertwingly.net>
AuthorDate: Sat Sep 23 15:58:58 2017 -0400

    flush cache of agendas parsed with previous versions of the library
---
 lib/whimsy/asf.rb                 | 2 +-
 www/board/agenda/models/agenda.rb | 6 ++++++
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/lib/whimsy/asf.rb b/lib/whimsy/asf.rb
index 68e29a7..60d2f0e 100644
--- a/lib/whimsy/asf.rb
+++ b/lib/whimsy/asf.rb
@@ -27,7 +27,7 @@ module ASF
   def self.library_mtime
     parent_dir = File.dirname(File.expand_path(__FILE__))
     sources = Dir.glob("#{parent_dir}/**/*")
-    times = sources.map {|source| File.mtime(source)}
+    times = sources.map {|source| File.mtime(source.untaint)}
     times.max.gmtime
   end
 
diff --git a/www/board/agenda/models/agenda.rb b/www/board/agenda/models/agenda.rb
index 9448ceb..5587fb6 100755
--- a/www/board/agenda/models/agenda.rb
+++ b/www/board/agenda/models/agenda.rb
@@ -14,6 +14,12 @@ class Agenda
   FileUtils.mkdir_p CACHE
   @@cache = Hash.new {|hash, key| hash[key] = {mtime: 0}}
 
+  # flush cache of files made with previous versions of the library
+  libmtime = ASF::library_mtime
+  Dir["#{CACHE}/*.yml"].each do |cache|
+    File.unlink(cache) if File.mtime(cache) < libmtime
+  end
+
   # fetch parsed agenda from in memory cache if up to date, otherwise
   # fall back to disk.
   def self.[](file)

-- 
To stop receiving notification emails like this one, please contact
"commits@whimsical.apache.org" <co...@whimsical.apache.org>.