mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-12 09:50:11 -05:00
Reduce alls to code search status endpoint (#3859)
Removes the automatic refresh because we see that the status (indexed vs not) does not change often
This commit is contained in:
@@ -8,7 +8,7 @@ import { shouldInclude } from '../../../../util/common/glob';
|
||||
import { Result } from '../../../../util/common/result';
|
||||
import { CallTracker, TelemetryCorrelationId } from '../../../../util/common/telemetryCorrelationId';
|
||||
import { coalesce } from '../../../../util/vs/base/common/arrays';
|
||||
import { IntervalTimer, raceCancellationError, raceTimeout } from '../../../../util/vs/base/common/async';
|
||||
import { raceCancellationError, raceTimeout } from '../../../../util/vs/base/common/async';
|
||||
import { CancellationToken, CancellationTokenSource } from '../../../../util/vs/base/common/cancellation';
|
||||
import { isCancellationError } from '../../../../util/vs/base/common/errors';
|
||||
import { Emitter, Event } from '../../../../util/vs/base/common/event';
|
||||
@@ -183,19 +183,14 @@ export class CodeSearchChunkSearch extends Disposable implements IWorkspaceChunk
|
||||
this.closeRepo(info.repo);
|
||||
}));
|
||||
|
||||
const refreshInterval = this._register(new IntervalTimer());
|
||||
refreshInterval.cancelAndSet(() => this.updateIndexedCommitForAllRepos(), 5 * 60 * 1000); // 5 minutes
|
||||
|
||||
// When the authentication state changes, update repos
|
||||
this._register(Event.any(
|
||||
this._authenticationService.onDidAuthenticationChange,
|
||||
this._adoCodeSearchService.onDidChangeIndexState
|
||||
)(() => {
|
||||
this._register(this._authenticationService.onDidAuthenticationChange(() => {
|
||||
this.updateRepoStatuses();
|
||||
}));
|
||||
|
||||
this._register(Event.any(
|
||||
this._authenticationService.onDidAdoAuthenticationChange
|
||||
this._authenticationService.onDidAdoAuthenticationChange,
|
||||
this._adoCodeSearchService.onDidChangeIndexState
|
||||
)(() => {
|
||||
this.updateRepoStatuses('ado');
|
||||
}));
|
||||
@@ -996,16 +991,6 @@ export class CodeSearchChunkSearch extends Disposable implements IWorkspaceChunk
|
||||
return undefined;
|
||||
}
|
||||
|
||||
private updateIndexedCommitForAllRepos(): void {
|
||||
this._logService.trace(`CodeSearchChunkSearch.updateIndexedCommitForAllRepos`);
|
||||
|
||||
for (const entry of this._codeSearchRepos.values()) {
|
||||
if (entry.repo.status === CodeSearchRepoStatus.Ready) {
|
||||
entry.repo.refreshStatusFromEndpoint(true, CancellationToken.None);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public deleteExternalIngestWorkspaceIndex(callTracker: CallTracker, token: CancellationToken): Promise<void> {
|
||||
return this._externalIngestIndex.value.deleteIndex(callTracker, token);
|
||||
}
|
||||
|
||||
@@ -263,7 +263,7 @@ abstract class BaseRemoteCodeSearchRepo extends Disposable implements CodeSearch
|
||||
return newState;
|
||||
}
|
||||
|
||||
private async fetchRemoteIndexState(token: CancellationToken): Promise<RemoteCodeSearchState> {
|
||||
protected async fetchRemoteIndexState(token: CancellationToken): Promise<RemoteCodeSearchState> {
|
||||
this._logService.trace(`CodeSearchChunkSearch.getRepoIndexStatusFromEndpoint(${this.repoInfo.rootUri}`);
|
||||
|
||||
const statusResult = await this.doFetchRemoteIndexState(token);
|
||||
@@ -418,12 +418,21 @@ export class GithubCodeSearchRepo extends BaseRemoteCodeSearchRepo {
|
||||
const startRepoStatus = this.status;
|
||||
|
||||
await measureExecTime(() => raceTimeout((async () => {
|
||||
if (this.status === CodeSearchRepoStatus.Ready) {
|
||||
// Try to update the indexed commit to ensure we're up to date
|
||||
const newState = await raceCancellationError(this.fetchRemoteIndexState(token), token);
|
||||
this.updateState(newState);
|
||||
return;
|
||||
}
|
||||
|
||||
// Trigger indexing if we have not already
|
||||
if (startRepoStatus === CodeSearchRepoStatus.NotYetIndexed) {
|
||||
if (this.status === CodeSearchRepoStatus.NotYetIndexed) {
|
||||
const triggerResult = await raceCancellationError(this.triggerRemoteIndexingOfRepo('auto', telemetryInfo), token);
|
||||
if (triggerResult.isError()) {
|
||||
throw new Error(`CodeSearchChunkSearch: Triggering indexing of '${this.remoteInfo.repoId}' failed: ${triggerResult.err.id}`);
|
||||
}
|
||||
|
||||
// Continue
|
||||
}
|
||||
|
||||
if (this.status === CodeSearchRepoStatus.BuildingIndex) {
|
||||
|
||||
Reference in New Issue
Block a user