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

Validate ActiveStorage::Blob io is rewindable #46548

Merged
merged 1 commit into from
Nov 23, 2022
Merged

Validate ActiveStorage::Blob io is rewindable #46548

merged 1 commit into from
Nov 23, 2022

Conversation

Earlopain
Copy link
Contributor

@Earlopain Earlopain commented Nov 22, 2022

Motivation / Background

Makes ActiveStorage::Blob.create_and_upload! raise on non-rewindable io. See #46507

ActiveStorage::Blob.create_and_upload!(io: file_fixture("test.jpg"), filename: "dummy")
ActiveStorage::Blob.create_and_upload!(io: file_fixture("test.jpg").read, filename: "dummy")

Both versions look reasonable, but only one works. Without the read call after file_fixture calculating the checksum loops infinitely. This will now propagate an error to the user instead.

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.
  • CI is passing.

@Earlopain

This comment was marked as outdated.

@Earlopain Earlopain changed the title Expand the note about rewindable io for Blobs Validate ActiveStorage::Blob io is rewindable Nov 23, 2022
    ActiveStorage::Blob.create_and_upload!(io: file_fixture("test.jpg"), filename: "dummy")

The code looks reasonable, but actually results in an infinite loop
before this change. Now an error is propagated to the user instead.
Closes #46507
@rafaelfranca rafaelfranca merged commit 153777d into rails:main Nov 23, 2022
@Earlopain Earlopain deleted the blob-rewindable branch November 23, 2022 19:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants