myexperiment-hackers
[Top][All Lists]
Advanced

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

[myexperiment-hackers] [3711] branches/packs/app/models/research_object.


From: noreply
Subject: [myexperiment-hackers] [3711] branches/packs/app/models/research_object.rb: fixed bug with duplicate proxies
Date: Wed, 18 Sep 2013 13:55:28 +0000 (UTC)

Revision
3711
Author
dgc
Date
2013-09-18 13:55:28 +0000 (Wed, 18 Sep 2013)

Log Message

fixed bug with duplicate proxies

Modified Paths

Diff

Modified: branches/packs/app/models/research_object.rb (3710 => 3711)


--- branches/packs/app/models/research_object.rb	2013-09-18 13:54:44 UTC (rev 3710)
+++ branches/packs/app/models/research_object.rb	2013-09-18 13:55:28 UTC (rev 3711)
@@ -21,6 +21,8 @@
 
   has_many :resources, :dependent => :destroy
 
+  has_many :proxies, :class_name => 'Resource', :conditions => { :is_proxy => true }
+
   has_many :annotation_resources
 
   belongs_to :context, :polymorphic => true
@@ -373,14 +375,16 @@
 
     path = calculate_path(opts[:path], opts[:content_type])
 
-    # Create a proxy for this resource.
+    # Create a proxy for this resource if it doesn't exist.
 
-    proxy = create_proxy(
-      :proxy_for_path => path,
-      :proxy_in_path  => ".",
-      :user_uri       => opts[:user_uri])
+    unless proxies.exists?(:proxy_for_path => path)
+      proxy = create_proxy(
+        :proxy_for_path => path,
+        :proxy_in_path  => ".",
+        :user_uri       => opts[:user_uri])
 
-    proxy.update_graph!
+      proxy.update_graph!
+    end
 
     # Create the resource.
 

reply via email to

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