-
Notifications
You must be signed in to change notification settings - Fork 462
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AO3-5578 Use ActiveStorage for existing image uploads #4807
base: master
Are you sure you want to change the base?
Conversation
Because ActiveStorage doesn't support prefixes within buckets well, we'll need to update the Ansible local config to separate things out IMO that's better anyways, since we currently co-mingle some production and non-production things... 😬 There's probably a way to do this with less friction, but I think this should be OK since we're copying things over |
Looks like #4738 (AO3-6324' comments) agree with you. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had a look at all the code except for the rake task.
The fixtures in test/fixtures/pseuds.yml
have (empty) lines for icon_file_name
, icon_content_type
, icon_updated_at
and icon_file_size
that should probably be removed.
I think there should be a followup Jira issue to remove the icon_file_name
, icon_content_type
, icon_updated_at
and icon_file_size
columns from the database for the affected classes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few final comments. The rake task looks good, as does the rest of the code.
I also tried a few things in local dev, including looking at various icons in various places, uploading a pseud icon and using that to test the validator and resizing. Resizing acts the same as on production.
return unless delete_icon? | ||
|
||
self.icon.purge | ||
self.icon_alt_text = nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should the description of the delete icon checkbox on the collection form be updated to mention that it deletes the alt text? The pseud form mentions it, see #4794.
Speaking of, it looks like that text and AO3-6608 also say that the comment text of the pseud icon should be deleted, but it looks like that slipped through, it's not deleted. This PR is already fixing things, so maybe that bug can be fixed too.
@@ -85,7 +85,7 @@ def check_for_spam | |||
includes( | |||
pseud: { user: [:roles, :block_of_current_user, :block_by_current_user, :preference] }, | |||
parent: { work: [:pseuds, :users] } | |||
) | |||
).merge(Pseud.with_attached_icon) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Piggy-backing off of this change, but this is a more general comment.
This scope got introduced because paperclip stored attachments directly on the model but Active Storage stores them in extra tables, meaning extra queries. That means that all places where a list of pseuds/collections/skins with icons is shown should also have the scope or this PR will introduce a lot of N+1 queries. The following places should likely use a with_attached_icon
scope:
pseuds#index
blocked/users#index
muted/users#index
collections#index
collection_items#index
challenge_assignments#index
challenge_claims#index
skins#index
people#index
people#search
inbox comments? Those also have other N+1 issues, see AO3-4412.
record.errors.add(attribute, :invalid_format) unless allowed_formats.include?(value.content_type) | ||
end | ||
|
||
record.errors.add(attribute, :too_large, size_limit_kb: size_limit_kb) unless value.blob.byte_size < maximum_size |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
size_limit_kb
isn't defined, but maximum_size
has the wrong unit.
Icon file size must be less than 512000 KB
to_fs, combined with removing the "KB" from the locale, should do the job.
record.errors.add(attribute, :too_large, size_limit_kb: size_limit_kb) unless value.blob.byte_size < maximum_size | |
record.errors.add(attribute, :too_large, size_limit: maximum_size.to_fs(:human_size)) unless value.blob.byte_size < maximum_size |
Pull Request Checklist
Issue
https://otwarchive.atlassian.net/browse/AO3-5578
Purpose
Migrate existing places that use kt-paperclip to ActiveStorage (pseud, collection, and skin icons)
Credit
Brian Austin (they/he)