Fix: prevent bitstream format cache issue by disabling cached version#4212
Fix: prevent bitstream format cache issue by disabling cached version#4212tdonohue merged 3 commits intoDSpace:mainfrom jesielviana:fix-bitstream-unable-to-change-format
Conversation
|
@atarix83 : This PR solves a bug ticket that had been assigned to you last week. Would you be willing to simply review this PR? If it looks good to you too, then we can get this merged quickly & take that ticket off your plate. |
FrancescoMolinaro
left a comment
There was a problem hiding this comment.
Hi @jesielviana, thanks for the changes and for looking into this!
I agree this is a caching issue, but I believe it would be better to invalidate the cache only for the modified bitstream.
In this way we could still make use of the cache for the unmodified bitstreams.
I think should be enough to add something like
this.requestService.setStaleByHrefSubstring(formatResponse.payload._links.format.href)
or
this.requestService.setStaleByHrefSubstring(formatResponse.payload._links.self.href)
in src/app/bitstream-page/edit-bitstream-page/edit-bitstream-page.component.ts.
(src/app/core/data/request.service.ts is not currently part of the component's dependencies)
We should be able to handle the cache invalidation in the onSubmit method of the component.
Let me know what you think about it and thanks again for looking into this!
|
Thank you, @FrancescoMolinaro. However, I couldn’t get it to work as expected. Thanks in advance! |
|
I've tried to invalidate the cache in bitstream-data.service.ts by replacing the line with:
and also tried:
However, after updating the format, the new value still doesn’t appear to be reflected in the UI. |
|
Hi @jesielviana , thanks for looking into it! I have digged a bit more into the issue and I found out that the object is not cached by href but by request uuid. ` // Delete also cache by uuid as the format could be cached also there this.objectCache.getByHref(bitsreamFormatUrl).pipe(take(1)).subscribe((cachedRequest) => { I tested this in a local environment and seems to be working. Thanks again for looking into it, much appreciated! |
|
Thanks, @FrancescoMolinaro! This works perfectly. I’ve applied your suggestion in the code and pushed the changes. I just replaced the deprecated Really appreciate your help—thanks again! |
tdonohue
left a comment
There was a problem hiding this comment.
👍 Thanks @jesielviana & @FrancescoMolinaro ! I tested the updated code today and it's working perfectly. I was also able to verify that this bug exists in 8.x (is reproducible on demo.dspace.org) and also looks to exist in 7.x (code is the same), so I'll port this back to those releases as well.
|
Backport failed for Please cherry-pick the changes locally and resolve any conflicts. git fetch origin dspace-7_x
git worktree add -d .worktree/backport-4212-to-dspace-7_x origin/dspace-7_x
cd .worktree/backport-4212-to-dspace-7_x
git switch --create backport-4212-to-dspace-7_x
git cherry-pick -x 600165210190fb1389abe108b0a6e2aea5cfb6b2 4f48f39f7b24903eaea4a639a894520469e4fe95 bb536192c27df34222a3e9ea9532a0b1f1854555 |
|
Successfully created backport PR for |
References
Description
Disable cache to ensure the updated bitstream format is displayed immediately after update.
Instructions for Reviewers
Fixes an issue where bitstream format changes did not appear immediately after saving due to cached data. Cache is now disabled specifically when fetching the bitstream's format to ensure the updated value is shown.
Steps to reproduce the behavior:
List of changes in this PR:
followLink('format')by setting{ useCachedVersionIfAvailable: false }initem-edit-bitstream-bundle.component.ts.Checklist
This checklist provides a reminder of what we are going to look for when reviewing your PR. You do not need to complete this checklist prior creating your PR (draft PRs are always welcome).
However, reviewers may request that you complete any actions in this list if you have not done so. If you are unsure about an item in the checklist, don't hesitate to ask. We're here to help!
mainbranch of code (unless it is a backport or is fixing an issue specific to an older branch).npm run lintnpm run check-circ-deps)package.json), I've made sure their licenses align with the DSpace BSD License based on the Licensing of Contributions documentation.