pad file name with creation date
During zip creation, when 2 files have an identical name it creates a corrupted zip file Duplicate files can now be downloaded with all the versions, the file names contain a timestamp
This commit is contained in:
parent
def81f9de8
commit
48b96046f1
1 changed files with 9 additions and 1 deletions
|
@ -16,13 +16,21 @@ class ActiveStorage::DownloadableFile
|
|||
pjs.map do |piece_justificative|
|
||||
[
|
||||
piece_justificative,
|
||||
piece_justificative.filename.to_s
|
||||
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
|
||||
|
|
Loading…
Reference in a new issue