Skip to content

Commit

Permalink
fix: reset cache in case of thrown error during resolve
Browse files Browse the repository at this point in the history
  • Loading branch information
nytamin committed Oct 3, 2024
1 parent 7e8de97 commit fd80f85
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/resolver/CacheHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ export class CacheHandler {

if (!cache.canBeUsed) {
// Reset the cache:
cache.objHashes = {}
cache.objects = {}
CacheHandler.resetCache(cache)

this.canUseIncomingCache = false
} else {
Expand Down Expand Up @@ -208,6 +207,12 @@ export class CacheHandler {

toc()
}
/** Resets / Clears the cache */
static resetCache(cache: Partial<ResolverCache>): void {
delete cache.canBeUsed
cache.objHashes = {}
cache.objects = {}
}
}
/** Return a "hash-string" which changes whenever anything that affects timing of a timeline-object has changed. */
export function hashTimelineObject(obj: ResolvedTimelineObject): string {
Expand Down
5 changes: 5 additions & 0 deletions src/resolver/ResolverHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,11 @@ export class ResolverHandler<TContent extends Content = Content> {
toc()
return resolvedTimeline
} catch (e) {
if (this.options.cache) {
// Reset cache, since it might be corrupt.
CacheHandler.resetCache(this.options.cache)
}

throw new ResolveError(e, this.resolvedTimeline.getResolvedTimeline())
}
}
Expand Down

0 comments on commit fd80f85

Please sign in to comment.