mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-27 01:43:22 +00:00
Ensure directory exists before saving pdf
These directories can get wiped during deployments
This commit is contained in:
@@ -13,6 +13,8 @@ class BulkInvoiceJob < ApplicationJob
|
||||
pdf << CombinePDF.parse(invoice)
|
||||
end
|
||||
|
||||
ensure_directory_exists filepath
|
||||
|
||||
pdf.save filepath
|
||||
|
||||
broadcast(filepath, options[:channel]) if options[:channel]
|
||||
@@ -41,4 +43,10 @@ class BulkInvoiceJob < ApplicationJob
|
||||
).
|
||||
broadcast
|
||||
end
|
||||
|
||||
def ensure_directory_exists(filepath)
|
||||
return unless File.exist?(File.dirname(filepath))
|
||||
|
||||
FileUtils.mkdir_p(File.dirname(filepath))
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user