Skip to content

Commit 4f48f39

Browse files
committed
fix: invalidate cache only for the modified bitstream
1 parent 6001652 commit 4f48f39

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

src/app/core/data/bitstream-data.service.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,12 +163,23 @@ export class BitstreamDataService extends IdentifiableDataService<Bitstream> imp
163163
sendRequest(this.requestService),
164164
take(1),
165165
).subscribe(() => {
166-
this.requestService.removeByHrefSubstring(bitstream.self + '/format');
166+
this.deleteFormatCache(bitstream);
167167
});
168-
169168
return this.rdbService.buildFromRequestUUID(requestId);
170169
}
171170

171+
private deleteFormatCache(bitstream: Bitstream) {
172+
const bitsreamFormatUrl = bitstream.self + '/format';
173+
this.requestService.setStaleByHrefSubstring(bitsreamFormatUrl);
174+
// Delete also cache by uuid as the format could be cached also there
175+
this.objectCache.getByHref(bitsreamFormatUrl).pipe(take(1)).subscribe((cachedRequest) => {
176+
const requestUuid = cachedRequest.requestUUIDs[0];
177+
if (this.requestService.hasByUUID(requestUuid)) {
178+
this.requestService.setStaleByUUID(requestUuid);
179+
}
180+
});
181+
}
182+
172183
/**
173184
* Returns an observable of {@link RemoteData} of a {@link Bitstream}, based on a handle and an
174185
* optional sequenceId or filename, with a list of {@link FollowLinkConfig}, to automatically

src/app/item-page/edit-item-page/item-bitstreams/item-edit-bitstream-bundle/item-edit-bitstream-bundle.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ export class ItemEditBitstreamBundleComponent implements OnInit, OnDestroy {
246246
switchMap(() => this.bundleService.getBitstreams(
247247
this.bundle.id,
248248
paginatedOptions,
249-
followLink('format', { useCachedVersionIfAvailable: false }),
249+
followLink('format'),
250250
)),
251251
);
252252
}),

0 commit comments

Comments
 (0)