[ARVADOS] updated: 36d6d1609ef342268cc87fc8bfce51bcf7199929

git at public.curoverse.com git at public.curoverse.com
Thu Feb 5 16:57:36 EST 2015


Summary of changes:
 services/api/lib/current_api_client.rb | 21 ++++++++++++++++++---
 1 file changed, 18 insertions(+), 3 deletions(-)

       via  36d6d1609ef342268cc87fc8bfce51bcf7199929 (commit)
      from  e20040092b47f79365637dd8e26156d95ab5c6ee (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.


commit 36d6d1609ef342268cc87fc8bfce51bcf7199929
Author: Tom Clegg <tom at curoverse.com>
Date:   Thu Feb 5 16:22:34 2015 -0500

    Avoid optional disk cache usage if it is owned by a different user. refs #2659.

diff --git a/services/api/lib/current_api_client.rb b/services/api/lib/current_api_client.rb
index 197dcd8..6c1ff28 100644
--- a/services/api/lib/current_api_client.rb
+++ b/services/api/lib/current_api_client.rb
@@ -187,9 +187,24 @@ module CurrentApiClient
   # If the given value is nil, or the cache has been cleared since it
   # was set, yield. Otherwise, return the given value.
   def check_cache value
-    Rails.cache.fetch "CurrentApiClient.$globals" do
-      value = nil
-      true
+    if not Rails.env.test? and
+        ActionController::Base.cache_store.is_a? ActiveSupport::Cache::FileStore and
+        not File.owned? ActionController::Base.cache_store.cache_path
+      # If we don't own the cache dir, we're probably
+      # crunch-dispatch. Whoever we are, using this cache is likely to
+      # either fail or screw up the cache for someone else. So we'll
+      # just assume the $globals are OK to live forever.
+      #
+      # The reason for making the globals expire with the cache in the
+      # first place is to avoid leaking state between test cases: in
+      # production, we don't expect the database seeds to ever go away
+      # even when the cache is cleared, so there's no particular
+      # reason to expire our global variables.
+    else
+      Rails.cache.fetch "CurrentApiClient.$globals" do
+        value = nil
+        true
+      end
     end
     return value unless value.nil?
     yield

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list