From d34d63cfe0e62ba3d3dfdf822ca89f5b0408baeb Mon Sep 17 00:00:00 2001 From: Ikhun Um Date: Mon, 7 Oct 2024 17:31:46 +0900 Subject: [PATCH] clean up --- .../server/internal/mirror/MirrorRunner.java | 24 ++++++++++++------- .../project/settings/mirrors/MirrorForm.tsx | 6 +---- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/server/src/main/java/com/linecorp/centraldogma/server/internal/mirror/MirrorRunner.java b/server/src/main/java/com/linecorp/centraldogma/server/internal/mirror/MirrorRunner.java index 0913b43fc0..29b51902c7 100644 --- a/server/src/main/java/com/linecorp/centraldogma/server/internal/mirror/MirrorRunner.java +++ b/server/src/main/java/com/linecorp/centraldogma/server/internal/mirror/MirrorRunner.java @@ -82,15 +82,20 @@ public CompletableFuture run(String projectName, String mirrorId) } private CompletableFuture run(MirrorKey mirrorKey) { - final CompletableFuture future = - metaRepo(mirrorKey.projectName).mirror(mirrorKey.mirrorId).thenApplyAsync(mirror -> { - return mirror.mirror(workDir, commandExecutor, - mirrorConfig.maxNumFilesPerMirror(), - mirrorConfig.maxNumBytesPerMirror()); - }, worker); - // Remove the inflight request when the mirror task is done. - future.handleAsync((unused0, unused1) -> inflightRequests.remove(mirrorKey)); - return future; + try { + final CompletableFuture future = + metaRepo(mirrorKey.projectName).mirror(mirrorKey.mirrorId).thenApplyAsync(mirror -> { + return mirror.mirror(workDir, commandExecutor, + mirrorConfig.maxNumFilesPerMirror(), + mirrorConfig.maxNumBytesPerMirror()); + }, worker); + // Remove the inflight request when the mirror task is done. + future.handleAsync((unused0, unused1) -> inflightRequests.remove(mirrorKey)); + return future; + } catch (Throwable e) { + inflightRequests.remove(mirrorKey); + throw e; + } } private MetaRepository metaRepo(String projectName) { @@ -103,6 +108,7 @@ public void close() { if (interrupted) { Thread.currentThread().interrupt(); } + inflightRequests.clear(); } private static final class MirrorKey { diff --git a/webapp/src/dogma/features/project/settings/mirrors/MirrorForm.tsx b/webapp/src/dogma/features/project/settings/mirrors/MirrorForm.tsx index f54fdc4889..e7e86caa17 100644 --- a/webapp/src/dogma/features/project/settings/mirrors/MirrorForm.tsx +++ b/webapp/src/dogma/features/project/settings/mirrors/MirrorForm.tsx @@ -72,10 +72,6 @@ const MIRROR_SCHEMES: OptionType[] = ['git+ssh', 'git+http', 'git+https'].map((s const INTERNAL_REPOS = new Set(['dogma', 'meta']); -type MirrorForm = MirrorDto & { - enableSchedule: boolean; -}; - const MirrorForm = ({ projectName, defaultValue, onSubmit, isWaitingResponse }: MirrorFormProps) => { const { register, @@ -85,7 +81,7 @@ const MirrorForm = ({ projectName, defaultValue, onSubmit, isWaitingResponse }: setValue, control, watch, - } = useForm(); + } = useForm(); const isNew = defaultValue.id === ''; const { data: repos } = useGetReposQuery(projectName);