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);