fix(server): preserve active VCS cache entries
This commit is contained in:
1 parent
f891d526de
commit
4a4df05191
2 files changed
+11
-2
No files matched your search
@@ -296,7 +296,7 @@ function enforceRetention(input: {
|
||||
(left, right) => left.mtimeMs - right.mtimeMs || left.filePath.localeCompare(right.filePath),
|
||||
)) {
|
||||
if (totalBytes <= input.maxTotalBytes) break;
|
||||
remove(file);
|
||||
if (!remove(file)) break;
|
||||
}
|
||||
|
||||
return { failures, removedCount, totalBytes };
|
||||
|
||||
@@ -190,6 +190,7 @@ export const make = Effect.gen(function* () {
|
||||
Scope.close(scope, Exit.void),
|
||||
);
|
||||
const statusCache = new Map<string, CachedVcsStatus>();
|
||||
const activeRemotePollerCwds = new Set<string>();
|
||||
const pollersRef = yield* SynchronizedRef.make(new Map<string, ActiveRemotePoller>());
|
||||
|
||||
const setCachedStatus = (cwd: string, status: CachedVcsStatus) => {
|
||||
@@ -197,7 +198,13 @@ export const make = Effect.gen(function* () {
|
||||
statusCache.set(cwd, status);
|
||||
|
||||
while (statusCache.size > VCS_STATUS_CACHE_CAPACITY) {
|
||||
const oldestCwd = statusCache.keys().next().value;
|
||||
let oldestCwd: string | undefined;
|
||||
for (const cachedCwd of statusCache.keys()) {
|
||||
if (!activeRemotePollerCwds.has(cachedCwd)) {
|
||||
oldestCwd = cachedCwd;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (oldestCwd === undefined) {
|
||||
break;
|
||||
}
|
||||
@@ -489,6 +496,7 @@ export const make = Effect.gen(function* () {
|
||||
return makeRemoteRefreshLoop(cwd, automaticRemoteRefreshInterval, refreshImmediately).pipe(
|
||||
Effect.forkIn(broadcasterScope),
|
||||
Effect.map((fiber) => {
|
||||
activeRemotePollerCwds.add(cwd);
|
||||
const nextPollers = new Map(activePollers);
|
||||
nextPollers.set(cwd, {
|
||||
fiber,
|
||||
@@ -531,6 +539,7 @@ export const make = Effect.gen(function* () {
|
||||
}
|
||||
|
||||
return Effect.sync(() => {
|
||||
activeRemotePollerCwds.delete(cwd);
|
||||
statusCache.delete(cwd);
|
||||
return [undefined, activePollers] as const;
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user