-
Notifications
You must be signed in to change notification settings - Fork 0
Pin Hyrax version for chunk upload fix #359
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
Merged
Merged
Changes from 6 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
8f78050
Pin Hyrax version for chunk upload fix
ShanaLMoore c2f879b
Update bundler.d/example.rb
ShanaLMoore aed2eda
Fix bundler inject
ShanaLMoore d2db511
Merge branch 'chunk-upload-fix' of https://github.com/notch8/palni_pa…
ShanaLMoore eff5122
:bug: Correct race condition in chunked uploads
ShanaLMoore f631259
💄 rubocop fixes
ShanaLMoore 183a048
♻️(uploads): Improve chunked upload atomicity and reliability
ShanaLMoore 527874b
remove redundant comment
ShanaLMoore e689b57
updates hyrax for chunk upload fix
ShanaLMoore File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| # OVERRIDE Hyrax v5.0.4 to fix a race condition in chunked uploads for multi-pod environments with a shared file system. | ||
| # To prevent file corruption from stale cache reads, the file size is now read directly from the file handle to ensure an accurate size check. | ||
| module Hyrax | ||
| module UploadsControllerDecorator | ||
| private | ||
|
|
||
| def handle_chunk(content_range, chunk) | ||
| file_path = @upload.file.path | ||
|
|
||
| current_size = 0 | ||
| File.open(file_path, 'r') { |f| current_size = f.size } if file_path && File.exist?(file_path) | ||
|
|
||
| begin_of_chunk = content_range[/\ (.*?)-/, 1].to_i | ||
|
|
||
| if @upload.file.present? && begin_of_chunk == current_size | ||
| File.open(file_path, 'ab') { |f| f.write(chunk.read) } | ||
|
ShanaLMoore marked this conversation as resolved.
Outdated
|
||
| else | ||
| @upload.file = chunk | ||
| end | ||
| end | ||
| end | ||
| end | ||
|
|
||
| Hyrax::UploadsController.prepend(Hyrax::UploadsControllerDecorator) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,3 +9,7 @@ | |
| ensure_gem "sentry-ruby" | ||
| ensure_gem "sentry-rails" | ||
| ensure_gem "cancancan", "~> 3.0" # cancancan is bundling to v1.17.0 but we need at least 3.0 | ||
|
|
||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This approach keeps the submodule’s Hyku version pinned to 315925a4 (the version currently deployed to production) while still incorporating the chunk upload fix by specifying the Hyrax version in bundler.d/example. |
||
| override_gem "hyrax", | ||
| github: "samvera/hyrax", | ||
| ref: "d6330a1c048bd498da852325a502f8dba0467c11" | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.