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
Include fcr:version in IIIF image URI #3165
Conversation
Use Rails' URI escape library because colon is handled differently.
Hi @dlpierce - we've been anticipating this one! What are your thoughts on this patch also being applied to Sufia while using the Universal Viewer? Would it work the same way? |
This is a creative approach! I think this could work, but am still wondering about IIIF manifests that are already in the wild. It seems like some guidance might be useful in the release notes. I think expiring the RIIIF cache after upgrading with this patch would temporarily solve this issue for both new and existing manifests. I'm guessing that if new versions are added for a file then it will still affect old manifests unless local RIIIF cache expiration happens. |
@cjcolvar - I agree, I believe the final solution will involve two parts. The iiif_endpoint change (which @dlpierce did above), and a change to the HTTPFileResolver. Like you said above, only newly cached network_files will work okay. As soon as a new version is ingested, and this runs again:
the previous version's image will be displayed since |
Using the file's parent FileSet timestamp from Solr might be a better performing solution since it should be able to avoid some requests to Fedora to determine available versions. There is still the preexisting Perhaps the riiif resover could compare its cached file's filesystem mtime to the FileSet timestamp? |
Looking at this again I have a small concern about manifests being downloaded after this change is applied and then being stuck with fedora specific path elements in the uri. Upgrading to a valkyrie-based Hyrax would probably break these uris unless special routes were added to continue to support them. I'm not sure if that should block this PR though which makes real progress in fixing a bug. @dlpierce Maybe the timestamp approach you mention would deal with this concern? |
Another way this could be fixed would be to create a listener to the Fedora messages and invalidate the cache entries when an appropriate message is received. |
@cjcolvar i'd be interested to hear @no-reply and others thoughts on whether we should be predictively flagging PRs based on what we think valkyrie based hyrax is going to look like. should we, instead, be flagging this type of thing as work we need to do on the valkyrie - hyrax sprints to ensure that this doesn't break? |
@@ -13,17 +13,18 @@ def display_image | |||
return nil unless ::FileSet.exists?(id) && solr_document.image? && current_ability.can?(:read, id) | |||
# @todo this is slow, find a better way (perhaps index iiif url): | |||
original_file = ::FileSet.find(id).original_file | |||
latest_file_id = original_file.has_versions? ? ActiveFedora::File.uri_to_id(original_file.versions.last.uri) : original_file.id |
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.
@dlpierce - I was just wondering - does this need to be encoded? So that Apache or the like doesn't receive a decoded path? I am learning a bit here and in my Suifa application, I had to apply your spec's ActionDispatch::Journey::Router::Utils.escape_segment(uri)
above so that the image requests went through ok.
@@ -13,17 +13,18 @@ def display_image | |||
return nil unless ::FileSet.exists?(id) && solr_document.image? && current_ability.can?(:read, id) | |||
# @todo this is slow, find a better way (perhaps index iiif url): | |||
original_file = ::FileSet.find(id).original_file | |||
latest_file_id = original_file.has_versions? ? ActiveFedora::File.uri_to_id(original_file.versions.last.uri) : original_file.id |
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.
Also, original_file.has_versions?
always seems to return true even when a file_set has only one version, so our iiif_endpoint
s changed for all our manifests, invalidating Rails.cache entries. Perhaps something like this is needed?:
latest_file_id = original_file.versions.count > 1 ? ActiveFedora::File.uri_to_id(original_file.versions.last.uri) : original_file.id
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.
The use of has_versions? was meant as a safeguard in case a file did not have support for versioning, although I do not know if that is really an issue in any application.
For now I'm working on the potential timestamp based solution.
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.
Thanks for the knowledge. And thanks for getting this solution going so we could begin applying it to Sufia.
Not sure if it helps to share, but we are experiencing some older version Riiif tiles still when a new file_set version derivative is not completed yet. FileSetPresenter#display_image
returns the new iiif_endpoint
using the new Fedora file version id, but when the images requests are sent to Riiif, the new file id invalidates the Rails.cache keys, sparking the file resolver to check it's cache for a matching hashed file name, but it's checking the derivative path and the timestamp of the old version. That new file can sometimes not be ready yet, since it is created in a background job.
What i plan to do is control the iiif_endpoint
change from some sort of after_perform
on the CreateDerivativesJob
- that way the derivative file will be ready when the HTTPFileResolver
fetches.
What I'm not 100% sure of yet is how I will control the versioning. I may just increment some solr field on the file_set that acts as the version.
Any thoughts from the community are welcome, even those that correct my thinking. All of this is new to me and I may be a smidgeon off.
Best,
Kevin
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
@dlpierce how can we unblock finishing this work? |
@no-reply I believe I can focus on this now that CircleCI is usable. |
@dlpierce any updates on this? tx |
I've been working on an alternative approach that doesn't modify the URIs, but instead compares timestamps. I plan to put that work in its own PR, so this one could be closed unless people think it should be used after all. |
Closed per suggestion from @dlpierce |
Fixes #2910
Include fcr:version in IIIF image URI so the cached file's hashed filename created by riiif is version specific.
Use Rails' URI escape library (instead of CGI) in the spec because colon is handled differently.
Guidance for testing, such as acceptance criteria or new user interface behaviors:
@samvera/hyrax-code-reviewers