-
Notifications
You must be signed in to change notification settings - Fork 5
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
Extend the storage adapters used for replaced derivative files #165
Extend the storage adapters used for replaced derivative files #165
Conversation
94f650a
to
8989b1b
Compare
This looks good, but seeing the repetitive changes made think about two small refactors that might be good:
|
@escowles thank you for this feedback. I can address this immediately.
Understood, I had also considered attempting to structure the usage of the |
@jrgriffiniii Yep, given that we're shifting to Valkyrie proper today, feel free to punt on those, I just thought I'd suggest them since I figured you'd push an update with a new or updated test. |
So I think that rubocop warning is valid (too many arguments is a problem.) We've also been pretty successful so far just passing the right storage adapter to the ChangeSetPersister. That extra branch feels like a magic conditional where I have to know which argument to pass in. I wonder if we can just toggle which storage adapter we pass in at the controller layer? |
Understood, I can address this as well.
I completely agree. I'm also not entirely comfortable given the complications which arise when taking into account the |
16849cf
to
3dda61e
Compare
private | ||
|
||
def file_typed_adapter(file:) | ||
file.derivative? ? @derivative_storage_adapter : @master_storage_adapter |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this'll work in the case of replacing derivatives from a file upload in the FileSet controller. Can't we just check the adapter for the previously existing file in that controller action and use that to upload?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm uncertain as to how this could be supported. @change_set
is initialized from the PATCH parameters passed to the Controller (via resource_params
):
def update
@change_set = change_set_class.new(find_resource(params[:id])).prepopulate!
authorize! :update, @change_set.resource
if @change_set.validate(resource_params)
@change_set.sync
obj = nil
change_set_persister.buffer_into_index do |persist|
obj = persist.save(change_set: @change_set)
end
def resource_params
params[resource_class.to_s.underscore.to_sym].to_unsafe_h
end
Example:
{"files"=>[{"473af163-d92c-4cb6-a036-63c0ce80a734"=>#<ActionDispatch::Http::UploadedFile:0x007fdc0aed0dd0 @tempfile=#<Tempfile:/var/folders/06/9nbfv2tx74jc0flpnq_mgz580000gp/T/RackMultipart20170927-472-4keg3b.jp2>, @original_filename="relax.jp2", @content_type="image/jp2", @headers="Content-Disposition: form-data; name=\"file_set[files[][473af163-d92c-4cb6-a036-63c0ce80a734]]\"; filename=\"test.jp2\"\r\nContent-Type: image/jp2\r\n">}]}
Because users can submit both master and derivative files into the same FileSetChangeSet
, I would need to initialize a different ChangeSet for each of these files, with a separate storage adapter passed to new PlumChangeSetPersister
's used for each of these ChangeSets.
3dda61e
to
1971ce4
Compare
… used for replaced, uploaded derivative files in FileSets Resolving styling issues
…ster for the afflicted FileSets using a new storage adapter (Valhalla::Storage::FileTypedDisk)
…der to segregate file uploads for original files from derivative files
b42fc40
to
97867f9
Compare
Resolves #109 by ensuring that the storage adapter for derivatives is used for replaced, uploaded derivative files in FileSets
[ ] Implement the(This was introduced upstream; please see Update Valkyrie and use Valkyrie.config.derivatives_adapter #260 )Valkyrie.config.derivatives_adapter
PlumChangeSetPersister
PlumChangeSetPersister
to load the adapter fromController
files