Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 Fix rerun for entries that came from zips #1013

Merged
merged 1 commit into from
Jan 29, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions app/models/bulkrax/importer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,14 @@ def import_metadata_format
# If the import data is zipped, unzip it to this path
def importer_unzip_path
@importer_unzip_path ||= File.join(parser.base_path, "import_#{path_string}")
return @importer_unzip_path if Dir.exist?(@importer_unzip_path)

# turns "tmp/imports/tenant/import_1_20250122035229_1" to "tmp/imports/tenant/import_1_20250122035229"
base_importer_unzip_path = @importer_unzip_path.split('_')[0...-1].join('_')

# If we don't have an existing unzip path, we'll try and find it.
# Just in case there are multiple paths, we sort by the number at the end of the path and get the last one
@importer_unzip_path = Dir.glob(base_importer_unzip_path + '*').sort_by { |path| path.split(base_importer_unzip_path).last[1..-1].to_i }.last
end

def errored_entries_csv_path
Expand Down
4 changes: 4 additions & 0 deletions app/parsers/bulkrax/csv_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,10 @@ def path_to_files(**args)
@path_to_files = File.join(
zip? ? importer_unzip_path : File.dirname(import_file_path), 'files', filename
)

return @path_to_files if File.exist?(@path_to_files)

File.join(importer_unzip_path, 'files', filename) if file? && zip?
end

private
Expand Down
Binary file added spec/fixtures/csv/files/moon.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.