Skip to content
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

Fix RedownloadMediaWorker #13741

Merged
merged 1 commit into from
May 12, 2020
Merged

Conversation

noellabo
Copy link
Contributor

No description provided.

@ClearlyClaire
Copy link
Contributor

Oh! Very good catch!
From what I understand, Remotable#reset_#{attr}! would only work reliably if the including class has a database-backed #{attr}_remote_url attribute, which is the case of every Remotable attribute except MediaAttachment, which has a remote_url instead of file_remote_url.

I guess the cleanest solution to this would be to rename remote_url to file_remote_url, but that would require a painful database migration.

Your solution is fine, but lib/mastodon/media_cli.rb needs to be fixed too.

An alternative might be to change Remotable's alt_method_name to url = has_attribute?(attribute_name) ? self[attribute_name] : self['remote_url']

@noellabo
Copy link
Contributor Author

Thank you! I will change to the method of suggestion.

@Gargron
Copy link
Member

Gargron commented May 12, 2020

I guess the cleanest solution to this would be to rename remote_url to file_remote_url, but that would require a painful database migration.

Or just define an alias on the MediaAttachment model

@ClearlyClaire
Copy link
Contributor

Or just define an alias on the MediaAttachment model

Would it work correctly with the self[attribute] and attribute= method?

@Gargron
Copy link
Member

Gargron commented May 12, 2020

Oh.. No, it wouldn't. But then maybe Remotable should be using methods and not attributes directly anyway to allow more flexibility. Another option is overriding the reset_file! method on MediaAttachment to make it do the right thing.

@Gargron Gargron merged commit 706972b into mastodon:master May 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants