archives: move bugreport

This commit is contained in:
Christophe Robillard 2021-08-04 15:08:14 +02:00
parent e947dd50e0
commit 031b74759f
2 changed files with 7 additions and 3 deletions

View file

@ -27,7 +27,7 @@ class ProcedureArchiveService
Zip::OutputStream.open(tmp_file) do |zipfile|
bug_reports = ''
files.each do |attachment, pj_filename|
zipfile.put_next_entry("procedure-#{@procedure.id}/#{pj_filename}")
zipfile.put_next_entry("#{zip_root_folder(@procedure)}/#{pj_filename}")
begin
zipfile.puts(attachment.download)
rescue
@ -35,7 +35,7 @@ class ProcedureArchiveService
end
end
if !bug_reports.empty?
zipfile.put_next_entry("LISEZMOI.txt")
zipfile.put_next_entry("#{zip_root_folder(@procedure)}/LISEZMOI.txt")
zipfile.puts(bug_reports)
end
end
@ -58,6 +58,10 @@ class ProcedureArchiveService
private
def zip_root_folder(procedure)
"procedure-#{@procedure.id}"
end
def create_list_of_attachments(dossiers)
dossiers.flat_map do |dossier|
ActiveStorage::DownloadableFile.create_list_from_dossier(dossier)