Skip to content

Commit 1c8030a

Browse files
committed
Don't save file to tmp
1 parent aa3b837 commit 1c8030a

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

lib/tasks/xml.rake

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ namespace :xml do
66
scope = ENV.fetch("SCOPE", "all_providers")
77
lang_param = ENV["LANGUAGE"]
88
provider_id = ENV["PROVIDER_ID"]
9-
dest = ENV["DEST"] || "tmp/all_providers_test.xml"
9+
dest = ENV["DEST"] || "all_providers_test.xml"
1010

1111
language = if lang_param.present?
1212
Language.find_by(id: lang_param) || Language.find_by(code: lang_param) || Language.find_by(name: lang_param)
@@ -31,17 +31,12 @@ namespace :xml do
3131
if dest == "-"
3232
puts xml
3333
else
34-
path = Rails.root.join(dest)
35-
FileUtils.mkdir_p(File.dirname(path))
36-
File.write(path, xml.encode("UTF-8", invalid: :replace, undef: :replace, replace: "�"), mode: "w:utf-8")
37-
puts "Wrote XML to #{path} (#{xml.bytesize} bytes)"
38-
39-
# Upload to Azure using FileWorker
34+
# Upload XML directly to Azure using FileWorker
4035
require_relative "../../app/services/file_worker"
4136
share = ENV["AZURE_STORAGE_SHARE_NAME"]
42-
name = File.basename(path)
37+
name = "all_providers_test.xml"
4338
azure_path = "" # root directory in Azure
44-
file_content = File.binread(path)
39+
file_content = xml.encode("UTF-8", invalid: :replace, undef: :replace, replace: "�")
4540

4641
FileWorker.new(
4742
share: share,

0 commit comments

Comments
 (0)