Skip to content

Commit 618345e

Browse files
author
Kirk Wang
committed
šŸ› Fix importing CSV as attachment
Prior to this commit, if an importer has a CSV file as an attachment, the importer would fail because it would try to parse the attached CSV as the importer CSV. This commit will add a condition to only look for a CSV file that is NOT in the `/files` directory. Ref: - #989
1 parent dfed1bb commit 618345e

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

ā€Žapp/parsers/bulkrax/csv_parser.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -379,9 +379,15 @@ def unique_collection_identifier(collection_hash)
379379
# We expect a single CSV at the top level of the zip in the CSVParser
380380
# but we are willing to go look for it if need be
381381
def real_import_file_path
382-
return Dir["#{importer_unzip_path}/**/*.csv"].first if file? && zip?
382+
return Dir["#{importer_unzip_path}/**/*.csv"].find { |path| not_in_files_dir?(path) } if file? && zip?
383383

384384
parser_fields['import_file_path']
385385
end
386+
387+
# If there are CSVs that are meant to be attachments in the files directory,
388+
# we don't want to consider them as the import CSV
389+
def not_in_files_dir?(path)
390+
!File.dirname(path).ends_with?('files')
391+
end
386392
end
387393
end

0 commit comments

Comments
Ā (0)