Skip to content

Commit

Permalink
fix: fixed purge
Browse files Browse the repository at this point in the history
  • Loading branch information
mbret committed Aug 23, 2024
1 parent c7da987 commit 574e1b1
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions packages/streamer/src/archives/archiveLoader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
merge,
mergeMap,
NEVER,
of,
shareReplay,
startWith,
Subject,
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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()

Expand Down

0 comments on commit 574e1b1

Please sign in to comment.