allow empty features on ArcGIS server

pull/16317/head
manmorjim 3 years ago
parent 959b8ed4b5
commit e4402543cb

@ -827,6 +827,7 @@ class DataImport < Sequel::Model
synchronization = CartoDB::Synchronization::Member.new(id: synchronization_id).fetch
synchronization.name = self.table_name
synchronization.log_id = log.id
byebug
if importer.success?
imported_table = ::Table.get_by_table_id(self.table_id)

@ -127,8 +127,7 @@ module CartoDB
return if resource_data.size.zero?
data = resource_data
else
return if resource_data.empty?
data = StringIO.new(resource_data)
data = resource_data.empty? ? StringIO.new : StringIO.new(resource_data)
end
name = filename

@ -13,6 +13,7 @@ module CartoDB
end
def run
byebug
data = parse(filepath)
return self if complex?(data)
File.open(converted_filepath, 'w') { |file| file.write csv_from(data) }
@ -54,7 +55,8 @@ module CartoDB
def parse(filepath)
return {} unless File.exists?(filepath)
file = File.open(filepath)
data = ::JSON.parse(file.read.force_encoding('UTF-8'))
raw_content = file.read.force_encoding('UTF-8')
data = raw_content.empty? ? {} : ::JSON.parse(raw_content)
file.close
data
end

@ -156,7 +156,7 @@ module CartoDB
def import(source_file, downloader, loader_object = nil)
loader = loader_object || loader_for(source_file).new(@job, source_file)
raise EmptyFileError if source_file.empty?
raise EmptyFileError if source_file.empty? && !can_be_empty(downloader.datasource)
loader.set_importer_stats(@importer_stats) if loader.respond_to?(:set_importer_stats)
loader.options = @loader_options.merge(tracker: tracker, importer_config: @importer_config)
@ -256,11 +256,9 @@ module CartoDB
end
@importer_stats.timing('unpack') do
if @downloader.source_file.present?
log.append "Unpacking #{@downloader.source_file.fullpath}"
tracker.call('unpacking')
unpacker.run(@downloader.source_file.fullpath)
end
log.append "Unpacking #{@downloader.source_file.fullpath}"
tracker.call('unpacking')
unpacker.run(@downloader.source_file.fullpath)
end
@importer_stats.timing('import') do
@ -445,6 +443,10 @@ module CartoDB
def delete_job_table
@job.delete_job_table
end
def can_be_empty(datasource)
return datasource.present? && datasource.is_a?(Datasources::Url::ArcGIS)
end
end
end
end

Loading…
Cancel
Save