[ActiveStorage for All] Add a storage-neutral file API to Hyrax::UploadedFile#7554
Draft
orangewolf wants to merge 1 commit into
Draft
[ActiveStorage for All] Add a storage-neutral file API to Hyrax::UploadedFile#7554orangewolf wants to merge 1 commit into
orangewolf wants to merge 1 commit into
Conversation
Introduces filename, content_type, byte_size, stored?, with_io, and with_local_path on Hyrax::UploadedFile as the supported interface for reading staged upload content, and adopts it in the storage-agnostic consumers: ValkyrieIngestJob, WorkUploadsHandler, the uploads JSON response, the collection branding transaction steps, and the dashboard collections controller. These call sites were reaching through the CarrierWave uploader (uploader.file.to_file, uploader.filename, file_url-as-local-path) and so were coupled to CarrierWave storing files at absolute local paths. Routing them through one narrow API prepares for an alternative Active Storage staging backend without behavior change today; with_io also deterministically closes the IO that ValkyrieIngestJob previously leaked. ActiveFedora-specific consumers (JobIoWrapper, FileActor, FileSetActor) intentionally keep using the CarrierWave interface unchanged. Tests: spec/models/hyrax/uploaded_file_spec.rb (new API coverage), spec/controllers/hyrax/uploads_controller_spec.rb, spec/services/hyrax/work_uploads_handler_spec.rb, spec/jobs/valkyrie_ingest_job_spec.rb, spec/hyrax/transactions/steps/save_collection_banner_spec.rb, spec/hyrax/transactions/steps/save_collection_logo_spec.rb, spec/controllers/hyrax/dashboard/collections_controller_spec.rb — all green locally against the koppie (Valkyrie) test app. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Test Results 17 files ± 0 17 suites ±0 3h 23m 4s ⏱️ - 6m 35s For more details on these failures, see this check. Results for commit bb199b2. ± Comparison against base commit 5cc41d6. This pull request removes 448 and adds 463 tests. Note that renamed tests count towards both. |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Part of the [ActiveStorage for All] chain (see #7553). This PR is a pure refactor — no behavior change.
Hyrax::UploadedFilegains a small storage-neutral API for reading staged content and metadata:#filename,#content_type,#byte_size,#stored?#with_io— yields a rewound binary IO with a real filesystem#path(what Valkyrie storage adapters need), closed deterministically after the block#with_local_path— yields a local path for copy-based consumersand the storage-agnostic consumers adopt it instead of reaching through the CarrierWave uploader:
ValkyrieIngestJob#upload_filefile.uploader.file.to_file(leaked the IO),.original_filenameHyrax::WorkUploadsHandler#file_set_argsfile.uploader.filenameuploads/create.json.jbuilderuploaded_file.file&.file&.filename/.sizeSaveCollectionBanner/SaveCollectionLogosteps,Dashboard::CollectionsControllerbrandingf.file_urlused as a local filesystem path (only works because CarrierWave'sstore_diris absolute)ActiveFedora-specific consumers (
JobIoWrapper,FileActor,FileSetActor) intentionally keep the CarrierWave interface — the AF ingest path is out of scope for this whole chain.Why
These call sites were coupled to CarrierWave storing files at absolute local paths. Routing them through one narrow interface lets a follow-up PR add an opt-in Active Storage staging backend without touching every consumer (and keeps that follow-up reviewable).
Dependencies
None (independent of #7553; the two merge in either order).
Supersedes #7548 (same change, moved from a fork branch to an in-repo branch and retitled).
Tests
Run locally against the koppie (Valkyrie) test app — dockerized Postgres/Solr/Redis:
spec/models/hyrax/uploaded_file_spec.rb— new coverage for the API (16 examples, 0 failures)spec/controllers/hyrax/uploads_controller_spec.rb,spec/services/hyrax/work_uploads_handler_spec.rb,spec/jobs/valkyrie_ingest_job_spec.rb,spec/hyrax/transactions/steps/save_collection_banner_spec.rb,spec/hyrax/transactions/steps/save_collection_logo_spec.rb(32 examples, 0 failures, 1 pending)spec/controllers/hyrax/dashboard/collections_controller_spec.rb(102 examples, 0 failures, 2 pending)AF-side (dassie) portions of the suite were not run locally; CI covers them. RuboCop clean on touched files;
git diff --checkclean.🤖 Generated with Claude Code