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 should honor the service: option #46825

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jnimety
Copy link
Contributor

@jnimety jnimety commented Dec 25, 2022

Motivation / Background

Fixes #46806

This Pull Request has been created because ActiveStorage::MirrorJob always uses the global/default service, even if an alternate service was specified via the :service option for has_*_attached

Detail

This Pull Request changes ActiveStorage::MirrorJob so the blob's service can be used to find mirrors instead of always using the global/default service.

Additional information

n/a

Checklist

Before submitting the PR make sure the following are checked:

  • This Pull Request is related to one change. Changes that are unrelated should be opened in separate PRs.
  • Commit message has a detailed description of what changed and why. If this PR fixes a related issue include it in the commit message. Ex: [Fix #issue-number]
  • Tests are added or updated if you fix a bug or add a feature.
  • CHANGELOG files are updated for the changed libraries if there is a behavior change or additional feature. Minor bug fixes and documentation changes should not be included.

@@ -9,7 +9,7 @@ class ActiveStorage::MirrorJob < ActiveStorage::BaseJob
discard_on ActiveStorage::FileNotFoundError
retry_on ActiveStorage::IntegrityError, attempts: 10, wait: :exponentially_longer

def perform(key, checksum:)
ActiveStorage::Blob.service.try(:mirror, key, checksum: checksum)
def perform(blob)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn’t backward compatible (if existing jobs are queued when you update rails). I think you’d need to write this in a way that supports both the new and old arguments. The old form can get deprecated and removed in the next rails release.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good point @ghiculescu. I've updated the PR to use the existing method signature.

@jnimety jnimety force-pushed the active-storage-mirror-job-incorrect-service branch 2 times, most recently from e5d459a to f02cf13 Compare January 13, 2023 00:31
@jnimety jnimety force-pushed the active-storage-mirror-job-incorrect-service branch from f02cf13 to d52d9aa Compare January 13, 2023 00:34
@jnimety
Copy link
Contributor Author

jnimety commented Feb 15, 2023

Would love to get this merged so I can remove my local patch. Anything left other than a final code review?

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