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