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
Using Fedora's If-Unmodified-Since header to prevent clobbering another client's writes #556
Conversation
…er client's writes
f368b9d
to
e1417ed
Compare
@HackMasterA are you still putting one token into your forms in Figgy? If this PR goes through it might be better to put them all into the form, since Fedora would have 2. @escowles This PR looks good to me. I think this approach with the separate lock makes the most sense given the time boundaries. |
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 like this approach much better.
I don't think we need to pass optimistic_locking_enabled?
down to the orm converter anymore, because once you've got the optimistic_lock_token
property populated it will be discarded when a resource is created if that field is not defined on the resource. This is how the casting works in other orm converters so I think it should work that way here. Can you try it without checking that value? It would make the code more consistent and reduce new lines of code here.
return unless lastmod | ||
|
||
token = Valkyrie::Persistence::OptimisticLockToken.new(adapter_id: "native-#{adapter.id}", token: DateTime.parse(lastmod.to_s).httpdate) | ||
resource.optimistic_lock_token << token |
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.
Access the property via its constant, Valkyrie::Persistence::Attributes::OPTIMISTIC_LOCK
@HackMasterA I'll see what I can do about not passing the optimistic_locking_enabled down, and using the OPTIMISTIC_LOCK constant (I couldn't get that to work with |
@escowles yeah I'm not sure about making it work with |
@HackMasterA Ready for re-review — both of those were easy to do! |
yay! |
Adding a second lock token for Fedora to hold the system-managed fedora:lastModified value, for use with the
If-Unmodified-Since
header.Fixes #522
Alternative to #531