Bug 37709: Die and notify if file cannot be opened

1 - perl misc/migration_tools/bulkmarcimport.pl -b --file=notafile.mrc -v
2 - Output:
    Characteristic MARC flavour: MARC21

    0 MARC records done in 0.00804400444030762 seconds
3 - Apply patch
4 - perl misc/migration_tools/bulkmarcimport.pl -b --file=notafile.mrc -v
5 - Output:
    Characteristic MARC flavour: MARC21
    Could not open notafile.mrc: No such file or directory at misc/migration_tools/bulkmarcimport.pl line 262.

Signed-off-by: Roman Dolny <roman.dolny@jezuici.pl>
Signed-off-by: Julian Maurice <julian.maurice@biblibre.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
This commit is contained in:
Nick Clemens 2024-08-22 11:35:45 +00:00 committed by Katrin Fischer
parent 80d4d3a586
commit 0546217cdc
Signed by: kfischer
GPG key ID: 0EF6E2C03357A834

View file

@ -255,7 +255,9 @@ my $searcher = Koha::SearchEngine::Search->new(
print "Characteristic MARC flavour: $marc_flavour\n" if $verbose; print "Characteristic MARC flavour: $marc_flavour\n" if $verbose;
my $starttime = gettimeofday; my $starttime = gettimeofday;
my $fh = IO::File->new($input_marc_file); # don't let MARC::Batch open the file, as it applies the ':utf8' IO layer # don't let MARC::Batch open the file, as it applies the ':utf8' IO layer
my $fh = IO::File->new($input_marc_file) or die "Could not open $input_marc_file: $!";
if ( defined $format && $format =~ /XML/i ) { if ( defined $format && $format =~ /XML/i ) {
# ugly hack follows -- MARC::File::XML, when used by MARC::Batch, # ugly hack follows -- MARC::File::XML, when used by MARC::Batch,