myexperiment-hackers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[myexperiment-hackers] [3398] branches/wf4ever/config/initializers/web_c


From: noreply
Subject: [myexperiment-hackers] [3398] branches/wf4ever/config/initializers/web_cache.rb: changed web cache so that it loads the manifest only once per request
Date: Wed, 6 Feb 2013 01:11:18 +0000 (UTC)

Revision
3398
Author
dgc
Date
2013-02-06 01:11:17 +0000 (Wed, 06 Feb 2013)

Log Message

changed web cache so that it loads the manifest only once per request

Modified Paths

Diff

Modified: branches/wf4ever/config/initializers/web_cache.rb (3397 => 3398)


--- branches/wf4ever/config/initializers/web_cache.rb	2013-02-05 17:00:55 UTC (rev 3397)
+++ branches/wf4ever/config/initializers/web_cache.rb	2013-02-06 01:11:17 UTC (rev 3398)
@@ -3,6 +3,18 @@
 # Copyright (c) 2013 University of Manchester and the University of Southampton.
 # See license.txt for details.
 
+class Thread
+  attr_accessor :read_manifest
+end
+
+ApplicationController # ensure that the application controller is loaded
+
+class ApplicationController
+  before_filter do |controller|
+    Thread.current.read_manifest = false
+  end
+end
+
 class ROSRS::Session
 
   alias_method :original_do_request, :do_request
@@ -18,9 +30,11 @@
       return false if uri.blank?
 
       # FIXME: The manifest check here is hacky.  This really ought to be done
-      # with appropriate HTTP headers.
+      # with appropriate HTTP headers.  I've added an attribute to the Thread
+      # class so that we can tell if we've read the manifest already whilst
+      # serving this request.
 
-      return false if uri.ends_with?("manifest.rdf")
+      return false if uri.ends_with?("manifest.rdf") && Thread.current.read_manifest == false
 
       File.exist?(cache_file_name(uri))
     end
@@ -44,6 +58,10 @@
       File.open(cache_file_name(uri), "w+") do |f|
         f.puts(envelope.to_yaml)
       end
+
+      # FIXME: The manifest handling here is hacky.
+
+      Thread.current.read_manifest = true if uri.ends_with?("manifest.rdf")
     end
 
     def delete_from_cache(uri)

reply via email to

[Prev in Thread] Current Thread [Next in Thread]