mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-27 01:43:22 +00:00
Expire report files after 1 week, maximum for S3
We didn't see this in tests which use disk storage. But AWS S3 has a maximum of one week for URL expiry.
This commit is contained in:
@@ -2,6 +2,9 @@
|
||||
|
||||
# Stores a generated report.
|
||||
class ReportBlob < ActiveStorage::Blob
|
||||
# AWS S3 limits URL expiry to one week.
|
||||
LIFETIME = 1.week
|
||||
|
||||
def self.create_for_upload_later!(filename)
|
||||
# ActiveStorage discourages modifying a blob later but we need a blob
|
||||
# before we know anything about the report file. It enables us to use the
|
||||
@@ -12,7 +15,7 @@ class ReportBlob < ActiveStorage::Blob
|
||||
checksum: "0",
|
||||
content_type: content_type(filename),
|
||||
).tap do |blob|
|
||||
ActiveStorage::PurgeJob.set(wait: 1.month).perform_later(blob)
|
||||
ActiveStorage::PurgeJob.set(wait: LIFETIME).perform_later(blob)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -35,6 +38,6 @@ class ReportBlob < ActiveStorage::Blob
|
||||
end
|
||||
|
||||
def expiring_service_url
|
||||
url(expires_in: 1.month)
|
||||
url(expires_in: LIFETIME)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -324,7 +324,7 @@ en:
|
||||
subject: "Report ready"
|
||||
heading: "Report ready for download"
|
||||
intro: |
|
||||
The link below will expire after one month.
|
||||
The link below will expire after one week.
|
||||
link_label: "%{name}"
|
||||
shipment_mailer:
|
||||
shipped_email:
|
||||
|
||||
Reference in New Issue
Block a user