Skip to content

Commit

Permalink
clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
ikhoon committed Oct 7, 2024
1 parent 19d095a commit d34d63c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,15 +82,20 @@ public CompletableFuture<MirrorResult> run(String projectName, String mirrorId)
}

private CompletableFuture<MirrorResult> run(MirrorKey mirrorKey) {
final CompletableFuture<MirrorResult> 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<MirrorResult> 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) {
Expand All @@ -103,6 +108,7 @@ public void close() {
if (interrupted) {
Thread.currentThread().interrupt();
}
inflightRequests.clear();
}

private static final class MirrorKey {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,6 @@ const MIRROR_SCHEMES: OptionType[] = ['git+ssh', 'git+http', 'git+https'].map((s

const INTERNAL_REPOS = new Set<string>(['dogma', 'meta']);

type MirrorForm = MirrorDto & {
enableSchedule: boolean;
};

const MirrorForm = ({ projectName, defaultValue, onSubmit, isWaitingResponse }: MirrorFormProps) => {
const {
register,
Expand All @@ -85,7 +81,7 @@ const MirrorForm = ({ projectName, defaultValue, onSubmit, isWaitingResponse }:
setValue,
control,
watch,
} = useForm<MirrorForm>();
} = useForm<MirrorDto>();

const isNew = defaultValue.id === '';
const { data: repos } = useGetReposQuery(projectName);
Expand Down

0 comments on commit d34d63c

Please sign in to comment.