5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2025-03-14 18:08:20 +00:00

Merge branch 'issue-17889' into 'rails'

Issue #17889

See merge request sutty/sutty!287
This commit is contained in:
fauno 2025-01-27 06:22:59 +00:00
commit 8cdde1b5ae

View file

@ -11,7 +11,7 @@ module ActiveStorage
# Permitir incrustar archivos subidos (especialmente PDFs) desde
# otros sitios.
def show
original_show.tap do |s|
original_show.tap do |_s|
response.headers.delete 'X-Frame-Options'
end
end
@ -24,7 +24,7 @@ module ActiveStorage
if (token = decode_verified_token)
if acceptable_content?(token)
blob = ActiveStorage::Blob.find_by_key! token[:key]
site = Site.find_by_name token[:service_name]
site = Site.find_by_name! token[:service_name]
if remote_file?(token)
begin
@ -32,18 +32,20 @@ module ActiveStorage
body = Down.download(url, max_size: 111.megabytes)
checksum = Digest::MD5.file(body.path).base64digest
blob.metadata[:url] = url
blob.update_columns checksum: checksum, byte_size: body.size, metadata: blob.metadata
blob.update_columns checksum:, byte_size: body.size, metadata: blob.metadata
rescue StandardError => e
ExceptionNotifier.notify_exception(e, data: { key: token[:key], url: url, site: site.name })
ExceptionNotifier.notify_exception(e, data: { key: token[:key], url:, site: site.name })
head :content_too_large
return
end
else
body = request.body
checksum = token[:checksum]
end
named_disk_service(token[:service_name]).upload token[:key], body, checksum: checksum
named_disk_service(site.name).upload(token[:key], body, checksum:)
site.static_files.attach(blob)
else
@ -52,7 +54,9 @@ module ActiveStorage
else
head :not_found
end
rescue ActiveStorage::IntegrityError
rescue ActiveRecord::ActiveRecordError, ActiveStorage::Error => e
ExceptionNotifier.notify_exception(e, data: { token: })
head :unprocessable_entity
end
@ -64,6 +68,9 @@ module ActiveStorage
def page_not_found(exception)
head :not_found
params.permit!
ExceptionNotifier.notify_exception(exception, data: { params: params.to_hash })
end
end