11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
# File 'lib/aqueduct/repositories/elastic.rb', line 11
def count_files(file_locators, file_type)
error = ''
file_paths = []
url_paths = []
file_locators.each do |file_locator|
file_locator = file_locator.to_s.gsub(/[\/*]/, '') file_type = file_type.to_s.gsub(/[\/*]/, '') file_name = file_locator + file_type
file_paths << file_name unless file_locator.blank?
end
name = "#{@source.name.gsub(/[^\w]/, '')}_#{file_type.split(/[_\.]/).select{|i| not i.blank?}.join('_').downcase}"
target_file_name = ''
= ''
result_hash = send_message("downloaders.json", { 'downloader[name]' => name, 'downloader[files]' => file_paths.join("\n"), 'downloader[folder]' => "source_#{@source.id}", 'downloader[comments]' => , 'target_file_name' => target_file_name, 'downloader[external_user_id]' => @current_user.id }, "post")
downloader_hash = result_hash[:result].blank? ? {} : ActiveSupport::JSON.decode(result_hash[:result])
url_paths = [downloader_hash['simple_executable_file_url']].compact
file_count = downloader_hash['file_count'].to_i
error = "Processing...retry in a few minutes." if url_paths.blank?
{ result: file_count, error: error, file_paths: file_paths, urls: url_paths }
end
|