From e9138fd660828cf29fdbe52247028a81bad0e514 Mon Sep 17 00:00:00 2001 From: atz Date: Thu, 12 Aug 2010 19:49:53 +0000 Subject: [PATCH] Allow * in file portion of pathname Example: incoming/*.xpo => incoming/yegagufoNy.xpo You cannot put an asterisk in the path portion of the string, however, since that would mean the target directory was not determined. git-svn-id: svn://svn.open-ils.org/ILS/trunk@17201 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- .../perlmods/OpenILS/Application/Acq/EDI.pm | 2 +- .../perlmods/OpenILS/Utils/RemoteAccount.pm | 21 +++++++++++++++++-- Open-ILS/src/support-scripts/edi_pusher.pl | 9 ++++++++ 3 files changed, 29 insertions(+), 3 deletions(-) diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Acq/EDI.pm b/Open-ILS/src/perlmods/OpenILS/Application/Acq/EDI.pm index f4fa24b968..815ce20f13 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Acq/EDI.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Acq/EDI.pm @@ -156,7 +156,7 @@ sub send_core { } elsif (! $_->edi) { $logger->error("Message (id " . $_->id. ") for $log_str has no EDI content"); $error = "EDI empty!"; - } elsif ($res = $server->put({remote_path => $account->path, content => $_->edi})) { + } elsif ($res = $server->put({remote_path => $account->path, content => $_->edi, single_ext => 1})) { # This is the successful case! $_->remote_file($res); $_->status('complete'); diff --git a/Open-ILS/src/perlmods/OpenILS/Utils/RemoteAccount.pm b/Open-ILS/src/perlmods/OpenILS/Utils/RemoteAccount.pm index fb08723a3c..971c8ca9ab 100644 --- a/Open-ILS/src/perlmods/OpenILS/Utils/RemoteAccount.pm +++ b/Open-ILS/src/perlmods/OpenILS/Utils/RemoteAccount.pm @@ -39,6 +39,7 @@ my %fields = ( local_file => undef, tempfile => undef, error => undef, + single_ext => undef, specific => 0, debug => 0, ); @@ -260,10 +261,26 @@ sub put { $self->{put_args} = [$local_file]; # same for scp_put and uFTP put if (defined $self->remote_path and not defined $self->remote_file) { - $self->remote_file($self->remote_path . '/' . basename($local_file)); # if we know just the dir + my $rpath = $self->remote_path; + my $fname = basename($local_file); + if ($rpath =~ /^(.*)\*+(.*)$/) { # if the path has an asterisk in it, like './incoming/*.tst' + my $head = $1; + my $tail = $2; + if ($tail =~ /\//) { + $logger->warn($self->_error("remote path '$rpath' has dir slashes AFTER an asterisk. Cannot determine target dir")); + return; + } + if ($self->single_ext) { + $tail =~ /\./ and $fname =~ s/\./_/g; # if dot in tail, replace dots in fname (w/ _) + } + $self->remote_file($head . $fname . $tail); + } else { + $self->remote_file($rpath . '/' . $fname); # if we know just the dir + } } + if (defined $self->remote_file) { - push @{$self->{put_args}}, $self->remote_file; # user can specify remote_file name, optionally + push @{$self->{put_args}}, $self->remote_file; # user can specify remote_file name, optionally } my %keys = $self->key_check($params); diff --git a/Open-ILS/src/support-scripts/edi_pusher.pl b/Open-ILS/src/support-scripts/edi_pusher.pl index eb7f29f6af..241ac562b6 100755 --- a/Open-ILS/src/support-scripts/edi_pusher.pl +++ b/Open-ILS/src/support-scripts/edi_pusher.pl @@ -55,6 +55,15 @@ print "\nHook '$hook' is used in ", scalar(@$defs), " event definition(s):\n"; $Data::Dumper::Indent = 1; my $remaining = $opts->{'max-batch-size'}; +# FIXME: this is the disclusion subquery. It discludes any PO that has +# a non-retry edi_message linked to it. But that means that if there are +# mutliple EDI messages (say, some failed translation) and one marked retry, +# the PO is still discluded! Perhaps there should never be multiple messages, +# but that makes testing much trickier (and is not DB-enforced). +# +# One approach might be to supplementally query for any "retry" messages that +# are on active providers (and deduplicate). + my $subq = { select => { acqedim => ['purchase_order'] }, from => 'acqedim', -- 2.43.2