From 970ad45906b1db6f02f19679f723318da4c22418 Mon Sep 17 00:00:00 2001 From: Shana Moore Date: Fri, 2 Aug 2024 14:41:18 -0700 Subject: [PATCH] :bug: Refactor: Fix file path access to prevent error - Centralized the import_file_path logic into a separate method - Resolved TypeError caused by nil values when checking file existence - Improved code readability and maintainability --- app/models/bulkrax/importer.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/models/bulkrax/importer.rb b/app/models/bulkrax/importer.rb index c89f7380..4ef79f2e 100644 --- a/app/models/bulkrax/importer.rb +++ b/app/models/bulkrax/importer.rb @@ -149,12 +149,16 @@ def seen @seen ||= {} end + def import_file_path + self.parser_fields['import_file_path'] + end + def original_file? - File.exist?(self.parser_fields['import_file_path']) + import_file_path && File.exist?(import_file_path) end def original_file - self.parser_fields['import_file_path'] if original_file? + import_file_path if original_file? end def replace_files