fix: invalidate cache only for the modified bitstream

This commit is contained in:
Jesiel Viana
2025-04-24 07:43:05 -03:00
committed by Tim Donohue
parent 8dbdb27c67
commit eac787f1f4
2 changed files with 14 additions and 3 deletions

View File

@@ -137,12 +137,23 @@ export class BitstreamDataService extends IdentifiableDataService<Bitstream> imp
sendRequest(this.requestService), sendRequest(this.requestService),
take(1) take(1)
).subscribe(() => { ).subscribe(() => {
this.requestService.removeByHrefSubstring(bitstream.self + '/format'); this.deleteFormatCache(bitstream);
}); });
return this.rdbService.buildFromRequestUUID(requestId); return this.rdbService.buildFromRequestUUID(requestId);
} }
private deleteFormatCache(bitstream: Bitstream) {
const bitsreamFormatUrl = bitstream.self + '/format';
this.requestService.setStaleByHrefSubstring(bitsreamFormatUrl);
// Delete also cache by uuid as the format could be cached also there
this.objectCache.getByHref(bitsreamFormatUrl).pipe(take(1)).subscribe((cachedRequest) => {
const requestUuid = cachedRequest.requestUUIDs[0];
if (this.requestService.hasByUUID(requestUuid)) {
this.requestService.setStaleByUUID(requestUuid);
}
});
}
/** /**
* Returns an observable of {@link RemoteData} of a {@link Bitstream}, based on a handle and an * Returns an observable of {@link RemoteData} of a {@link Bitstream}, based on a handle and an
* optional sequenceId or filename, with a list of {@link FollowLinkConfig}, to automatically * optional sequenceId or filename, with a list of {@link FollowLinkConfig}, to automatically

View File

@@ -203,7 +203,7 @@ export class ItemEditBitstreamBundleComponent implements OnInit, OnDestroy {
switchMap(() => this.bundleService.getBitstreams( switchMap(() => this.bundleService.getBitstreams(
this.bundle.id, this.bundle.id,
paginatedOptions, paginatedOptions,
followLink('format', { useCachedVersionIfAvailable: false }), followLink('format'),
)), )),
); );
}), }),