From 574e1b1170473ba715b5acd034a35ffcc7fdfcb4 Mon Sep 17 00:00:00 2001 From: Maxime Bret Date: Fri, 23 Aug 2024 21:58:15 +0200 Subject: [PATCH] fix: fixed purge --- packages/streamer/src/archives/archiveLoader.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/packages/streamer/src/archives/archiveLoader.ts b/packages/streamer/src/archives/archiveLoader.ts index 1c20d809..72facc1a 100644 --- a/packages/streamer/src/archives/archiveLoader.ts +++ b/packages/streamer/src/archives/archiveLoader.ts @@ -11,6 +11,7 @@ import { merge, mergeMap, NEVER, + of, shareReplay, startWith, Subject, @@ -94,7 +95,7 @@ export const createArchiveLoader = ({ return isUnlocked$.pipe( withLatestFrom(isPurged$), switchMap(([isUnlocked, isPurged]) => - !isUnlocked ? NEVER : timer(isPurged ? 1 : cleanArchiveAfter), + !isUnlocked ? NEVER : !isPurged ? timer(cleanArchiveAfter) : of(null), ), tap(() => { console.log("ARCHIVE DELETED") @@ -166,7 +167,14 @@ export const createArchiveLoader = ({ /** * Will purge immediatly archives as soon as they are released */ - const purge = () => purgeSubject.next() + const purge = () => { + // make sure we don't access anymore + Object.keys(archives).forEach((key) => { + delete archives[key] + }) + + purgeSubject.next() + } merge(cleanup$, archiveLoaded$).pipe(takeUntil(destroySubject)).subscribe()