Acq: Prevent problem in preventing EDI re-retrieves
authorLebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Tue, 29 Jan 2013 17:33:21 +0000 (12:33 -0500)
committerLebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Tue, 5 Feb 2013 22:17:26 +0000 (17:17 -0500)
The query we were using before would needlessly transfer large objects,
potentially hitting Jabber message size limits.

We're just testing for the existence of such objects, so we need no more
than a single ID in the result.

Signed-off-by: Lebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/EDI.pm

index 962ad41..a6b65a8 100644 (file)
@@ -117,19 +117,29 @@ sub retrieve_core {
             # same FTP site and credentials.  If we only checked based on
             # acq.edi_account.id, we'd not find out in those cases that we've
             # already processed the same file before.
-            my $hits = $e->search_acq_edi_message([
-                {
-                    "+acqedi" => {
-                        host => $account->host,
-                        username => $account->username,
-                        password => $account->password,
-                        in_dir => $account->in_dir
+            my $hits = $e->search_acq_edi_message(
+                [
+                    {
+                        "+acqedi" => {
+                            host => $account->host,
+                            username => $account->username,
+                            password => $account->password,
+                            in_dir => $account->in_dir
+                        },
+                        remote_file => $remote_file,
+                        status      => {'in' => [qw/ processed /]},
                     },
-                    remote_file => $remote_file,
-                    status      => {'in' => [qw/ processed /]},
-                },
-                { join => {"acqedi" => {}} }
-            ]);
+                    { join => {"acqedi" => {}}, limit => 1 }
+                ], { idlist => 1 }
+            );
+
+            if (!$hits) {
+                my $msg = "EDI: test for already-retrieved files yielded " .
+                    "event " . $e->event->{textcode};
+                $logger->warn($msg);
+                warn $msg;
+                return $e->die_event;
+            }
 
             if (@$hits) {
                 $logger->debug("EDI: $remote_file already retrieved.  Skipping");