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

ActiveStorage::MirrorJob always uses the default service, even if overridden via has_*_attached ..., service: :another_service #46806

Open
jnimety opened this issue Dec 23, 2022 · 3 comments · May be fixed by #46825

Comments

@jnimety
Copy link
Contributor

jnimety commented Dec 23, 2022

I ran into this when trying to migrate all of my attached from local storage to s3. After setting up mirroring and running ActiveStorage::Blob.find_each &:mirror_later I was surprised to find all of my attachments in the default storage service, even if a different service had been specified via has_*_attached ..., service: ...

I think the culprit is here:

ActiveStorage::Blob.service.try(:mirror, key, checksum: checksum)

ActiveStorage::Blob.service the default service. The other jobs pass blob to perform... Is there any reason not to pass blob here as well, and use blob.service instead of ActiveStorage::Blob.service?

If that's acceptable I'm happy to submit a PR. Thanks!

@ghiculescu
Copy link
Member

Yep that looks like a bug. Please submit a PR! You could add a test to verify the fix here.

@jnimety
Copy link
Contributor Author

jnimety commented Jan 4, 2023

I'm unfamiliar with the rails PR process... is there anything else I need to do to move this forward?

@skipkayhil
Copy link
Member

Your best bet is probably asking for a review in the Contributor Discord

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants