Merge pull request #5393 from betagouv/zip-with-identical-files

Zip with identical files
This commit is contained in:
Keirua 2020-07-20 15:35:35 +02:00 committed by GitHub
commit fd8507b531
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -15,14 +15,22 @@ class ActiveStorage::DownloadableFile
pjs = PiecesJustificativesService.liste_pieces_justificatives(dossier)
pjs.map do |piece_justificative|
[
ActiveStorage::DownloadableFile.new(piece_justificative),
piece_justificative.filename.to_s
piece_justificative,
self.timestamped_filename(piece_justificative)
]
end
end
private
def self.timestamped_filename(piece_justificative)
extension = File.extname(piece_justificative.filename.to_s)
basename = File.basename(piece_justificative.filename.to_s, extension)
timestamp = piece_justificative.created_at.strftime("%d-%m-%Y-%H-%S")
"#{basename}-#{timestamp}#{extension}"
end
def using_local_backend?
[:local, :local_test, :test].include?(Rails.application.config.active_storage.service)
end