diff --git a/NEWS.md b/NEWS.md index 19a324df15..8dd18f9866 100644 --- a/NEWS.md +++ b/NEWS.md @@ -100,6 +100,7 @@ Development * UI fixes for georeference. Changes of copy and validation warning. (#11426) * Color scheme is now clickable in category ramps (#11413) * Fix responsive layout in onboarding steps (#11444) +* Fix for race condition when importing files and deploying at the same time (#11653) * Correctly create custom category legend if style has icons (#11592) * Fix problem with perfect-scrollbar in Edge browsers (CartoDB/perfect-scrollbar/#2) * Layer onboardings are now aware on sync'd layers and highlighted area is clicked. (#11583) diff --git a/lib/tasks/import.rake b/lib/tasks/import.rake index 6fa59ac367..08da95fd97 100644 --- a/lib/tasks/import.rake +++ b/lib/tasks/import.rake @@ -31,7 +31,7 @@ namespace :cartodb do file_upload_helper = CartoDB::FileUpload.new(Cartodb.config[:importer].fetch("uploads_path", nil)) unless data_import_item.nil? - # be 100% safe en rescue blocks when trying to log the failed id + # be 100% safe in rescue blocks when trying to log the failed id data_import_item_id = data_import_item.id rescue nil begin @@ -40,15 +40,13 @@ namespace :cartodb do data_import_item.state = DataImport::STATE_PENDING data_import_item.save - filepath = data_import_item.data_source - filename = data_import_item.data_source.slice(data_import_item.data_source.rindex('/') + 1, - data_import_item.data_source.length) + filepath = File.realpath data_import_item.data_source + filename = File.basename data_import_item.data_source - uploads_path = file_upload_helper.get_uploads_path + uploads_path = File.realpath file_upload_helper.get_uploads_path - token = data_import_item.data_source.slice(/#{uploads_path}\/(.)+\//) - .sub("#{uploads_path}/", '') - .sub('/', '') + # Files are temp stored in "/%{uploads_path}/token/basename.ext" + token = File.basename File.dirname filepath file_uri = file_upload_helper.upload_file_to_s3(filepath, filename, token, Cartodb.config[:importer]['s3']) begin