URLVerify.pm; avoid re-processing same url repairs; honor delay=0
authorBill Erickson <berick@esilibrary.com>
Thu, 9 Aug 2012 20:06:34 +0000 (16:06 -0400)
committerBill Erickson <berick@esilibrary.com>
Thu, 9 Aug 2012 20:06:34 +0000 (16:06 -0400)
Signed-off-by: Bill Erickson <berick@esilibrary.com>
Open-ILS/src/perlmods/lib/OpenILS/Application/URLVerify.pm

index f379bbe..64ec64b 100644 (file)
@@ -375,9 +375,13 @@ sub collect_verify_attempt_and_settings {
 
     my $org = $attempt->session->owning_lib;
 
-    if (!$cache{delay}{$org}) {
+    if (!$cache{timeout}{$org}) {
+
         $cache{delay}{$org} = $U->ou_ancestor_setting_value(
-            $org, 'url_verify.url_verification_delay', $e) || 2;
+            $org, 'url_verify.url_verification_delay', $e);
+
+        # 0 is a valid delay
+        $cache{delay}{$org} = 2 unless defined $cache{delay}{$org};
 
         $cache{redirects}{$org} = $U->ou_ancestor_setting_value(
             $org, 'url_verify.url_verification_max_redirects', $e) || 20;
@@ -402,9 +406,9 @@ sub collect_verify_attempt_and_settings {
 }
 
 
-# finds the url_verfication for any url processed within this 
-# verification attempt whose full_url matches the full_url of 
-# the provided URL.
+# searches for a completed url_verfication for any url processed 
+# within this verification attempt whose full_url matches the 
+# full_url of the provided URL.
 sub find_matching_url_for_attempt {
     my ($e, $attempt, $url) = @_; 
 
@@ -420,6 +424,15 @@ sub find_matching_url_for_attempt {
             '+uvu' => {
                 id => {'!=' => $url->id},
                 full_url => $url->full_url
+            },
+
+            # There could be multiple verifications for matching URLs
+            # We only want a verification that completed.
+            # Note also that 2 identical URLs processed within the same
+            # sub-batch will have to each be fully processed in their own 
+            # right, since neither knows how the other will ultimately fare.
+            '+uvuv' => {
+                res_time => {'!=' => undef}
             }
         }
     })->[0];