From 518fcad2ca86fc585bf781f36842517b96d9af6b Mon Sep 17 00:00:00 2001 From: Mengwei Ding Date: Tue, 26 Feb 2019 14:53:53 +0800 Subject: [PATCH] [Code] Improve repository progress polling when clone/index is interrupted by delete --- .../code/public/sagas/project_status.ts | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/x-pack/plugins/code/public/sagas/project_status.ts b/x-pack/plugins/code/public/sagas/project_status.ts index e923ef5f72fb2..c17f82b32d9ef 100644 --- a/x-pack/plugins/code/public/sagas/project_status.ts +++ b/x-pack/plugins/code/public/sagas/project_status.ts @@ -145,6 +145,16 @@ const handleRepoCloneStatusPolling = createRepoStatusPollingHandler( } }, function*(status: any, repoUri: RepositoryUri) { + if ( + // Repository has been deleted during the clone + (!status.gitStatus && !status.indexStatus && !status.deleteStatus) || + // Repository is in delete during the clone + status.deleteStatus + ) { + // Stop polling git progress + return false; + } + if (status.gitStatus) { const { progress, cloneProgress } = status.gitStatus; yield put( @@ -180,6 +190,16 @@ const handleRepoIndexStatusPolling = createRepoStatusPollingHandler( } }, function*(status: any, repoUri: RepositoryUri) { + if ( + // Repository has been deleted during the index + (!status.gitStatus && !status.indexStatus && !status.deleteStatus) || + // Repository is in delete during the index + status.deleteStatus + ) { + // Stop polling index progress + return false; + } + if (status.indexStatus) { yield put( updateIndexProgress({ @@ -222,6 +242,7 @@ const handleRepoDeleteStatusPolling = createRepoStatusPollingHandler( repoUri, }) ); + return false; } if (status.deleteStatus) {