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

Using Fedora's If-Unmodified-Since header to prevent clobbering another client's writes #556

Merged
merged 2 commits into from Aug 9, 2018

Conversation

escowles
Copy link
Contributor

@escowles escowles commented Aug 8, 2018

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

@escowles escowles force-pushed the locking-so-nice-we-lock-it-twice branch from f368b9d to e1417ed Compare August 8, 2018 20:47
@carolyncole
Copy link
Contributor

@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.

Copy link
Contributor

@hackartisan hackartisan left a 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
Copy link
Contributor

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

@escowles
Copy link
Contributor Author

escowles commented Aug 9, 2018

@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 <<, but I didn't try very hard because the other stuff wasn't working yet).

@hackartisan
Copy link
Contributor

hackartisan commented Aug 9, 2018

@escowles yeah I'm not sure about making it work with <<. I know that for setting we had to do .send("#{CONSTANT}=") would it be similar for appending?

@escowles
Copy link
Contributor Author

escowles commented Aug 9, 2018

@HackMasterA Ready for re-review — both of those were easy to do!

@hackartisan
Copy link
Contributor

yay!

@awead awead merged commit 6c7101b into master Aug 9, 2018
@awead awead deleted the locking-so-nice-we-lock-it-twice branch August 9, 2018 14:16
@awead awead removed the Review label Aug 9, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants