| @@ -190,6 +190,7 @@ export const make = Effect.gen(function* () { · 189 unmodified lines |
| 190 | 190 | Scope.close(scope, Exit.void), |
| 191 | 191 | ); |
| 192 | 192 | const statusCache = new Map<string, CachedVcsStatus>(); |
| 193 | + const activeRemotePollerCwds = new Set<string>(); |
| 193 | 194 | const pollersRef = yield* SynchronizedRef.make(new Map<string, ActiveRemotePoller>()); |
| 194 | 195 | |
| 195 | 196 | const setCachedStatus = (cwd: string, status: CachedVcsStatus) => { |
| @@ -197,7 +198,13 @@ export const make = Effect.gen(function* () { · 1 unmodified line |
| 197 | 198 | statusCache.set(cwd, status); |
| 198 | 199 | |
| 199 | 200 | while (statusCache.size > VCS_STATUS_CACHE_CAPACITY) { |
| 200 | | − const oldestCwd = statusCache.keys().next().value; |
| 201 | + let oldestCwd: string | undefined; |
| 202 | + for (const cachedCwd of statusCache.keys()) { |
| 203 | + if (!activeRemotePollerCwds.has(cachedCwd)) { |
| 204 | + oldestCwd = cachedCwd; |
| 205 | + break; |
| 206 | + } |
| 207 | + } |
| 201 | 208 | if (oldestCwd === undefined) { |
| 202 | 209 | break; |
| 203 | 210 | } |
| @@ -489,6 +496,7 @@ export const make = Effect.gen(function* () { · 285 unmodified lines |
| 489 | 496 | return makeRemoteRefreshLoop(cwd, automaticRemoteRefreshInterval, refreshImmediately).pipe( |
| 490 | 497 | Effect.forkIn(broadcasterScope), |
| 491 | 498 | Effect.map((fiber) => { |
| 499 | + activeRemotePollerCwds.add(cwd); |
| 492 | 500 | const nextPollers = new Map(activePollers); |
| 493 | 501 | nextPollers.set(cwd, { |
| 494 | 502 | fiber, |
| @@ -531,6 +539,7 @@ export const make = Effect.gen(function* () { · 36 unmodified lines |
| 531 | 539 | } |
| 532 | 540 | |
| 533 | 541 | return Effect.sync(() => { |
| 542 | + activeRemotePollerCwds.delete(cwd); |
| 534 | 543 | statusCache.delete(cwd); |
| 535 | 544 | return [undefined, activePollers] as const; |
| 536 | 545 | }); |