Bug 20254: Do not ingest files with duplicate filenames
If the supplier delivers the same file twice we are unable to rename it on the second occurence causing us to download and process it infinitely. Check that downloaded filenames are unique against those on file and reject processing if a duplicate. This patch delays this check to the ingest stage so that the same code is processed irrespective of transport Signed-off-by: Mark Tompsett <mtompset@hotmail.com> Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
This commit is contained in:
parent
b8f382b821
commit
8b98403cbe
|
|
@ -182,6 +182,15 @@ sub sftp_download {
|
|||
sub ingest {
|
||||
my ( $self, $msg_hash, @downloaded_files ) = @_;
|
||||
foreach my $f (@downloaded_files) {
|
||||
|
||||
# Check file has not been downloaded already
|
||||
my $existing_file = $self->{schema}->resultset('EdifactMessage')
|
||||
->find( { filename => $f, } );
|
||||
if ($existing_file) {
|
||||
carp "skipping ingest of $f : filename exists";
|
||||
next;
|
||||
}
|
||||
|
||||
$msg_hash->{filename} = $f;
|
||||
my $file_content =
|
||||
read_file( "$self->{working_dir}/$f", binmode => ':raw' );
|
||||
|
|
|
|||
Loading…
Reference in New Issue