From 19d26545c73ee5f73e75a5500a0f47d345e9d850 Mon Sep 17 00:00:00 2001 From: Yevheniy Oliynyk Date: Tue, 11 Jun 2024 19:32:46 +0200 Subject: [PATCH] fix: sequential upload for sb projects (#815) --- .../crowdin/cli/commands/actions/UploadSourcesAction.java | 6 +++++- .../cli/commands/actions/UploadTranslationsAction.java | 6 +++++- .../com/crowdin/cli/utils/concurrency/ConcurrencyUtil.java | 3 +-- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/crowdin/cli/commands/actions/UploadSourcesAction.java b/src/main/java/com/crowdin/cli/commands/actions/UploadSourcesAction.java index 3d202005f..b298d3fdd 100644 --- a/src/main/java/com/crowdin/cli/commands/actions/UploadSourcesAction.java +++ b/src/main/java/com/crowdin/cli/commands/actions/UploadSourcesAction.java @@ -338,7 +338,11 @@ public void act(Outputter out, PropertiesWithFiles pb, ProjectClient client) { }) .collect(Collectors.toList()); - ConcurrencyUtil.executeAndWait(taskss, debug); + if (isStringsBasedProject) { + ConcurrencyUtil.executeAndWaitSingleThread(taskss, debug); + } else { + ConcurrencyUtil.executeAndWait(taskss, debug); + } }) .collect(Collectors.toList()); ConcurrencyUtil.executeAndWaitSingleThread(tasks, debug); diff --git a/src/main/java/com/crowdin/cli/commands/actions/UploadTranslationsAction.java b/src/main/java/com/crowdin/cli/commands/actions/UploadTranslationsAction.java index 1178f0caa..64d5807c7 100644 --- a/src/main/java/com/crowdin/cli/commands/actions/UploadTranslationsAction.java +++ b/src/main/java/com/crowdin/cli/commands/actions/UploadTranslationsAction.java @@ -226,7 +226,11 @@ public void act(Outputter out, PropertiesWithFiles pb, ProjectClient client) { }) .collect(Collectors.toList()); } - ConcurrencyUtil.executeAndWait(tasks, debug); + if (isStringsBasedProject) { + ConcurrencyUtil.executeAndWaitSingleThread(tasks, debug); + } else { + ConcurrencyUtil.executeAndWait(tasks, debug); + } if (containsErrors.get()) { throw new RuntimeException(RESOURCE_BUNDLE.getString("error.execution_contains_errors")); diff --git a/src/main/java/com/crowdin/cli/utils/concurrency/ConcurrencyUtil.java b/src/main/java/com/crowdin/cli/utils/concurrency/ConcurrencyUtil.java index 4250115e0..011f5dd05 100644 --- a/src/main/java/com/crowdin/cli/utils/concurrency/ConcurrencyUtil.java +++ b/src/main/java/com/crowdin/cli/utils/concurrency/ConcurrencyUtil.java @@ -20,7 +20,6 @@ private ConcurrencyUtil() { */ public static void executeAndWait(List tasks, boolean debug) { run(tasks, CROWDIN_API_MAX_CONCURRENT_REQUESTS, tasks.size() * 2, debug); - } public static void executeAndWaitSingleThread(List tasks, boolean debug) { @@ -28,7 +27,7 @@ public static void executeAndWaitSingleThread(List tasks, boolean debu } private static void run(List tasks, int threadQnt, int minutesWait, boolean debug) { - if (Objects.isNull(tasks) || tasks.size() == 0) { + if (Objects.isNull(tasks) || tasks.isEmpty()) { return; } ExecutorService executor = CrowdinExecutorService.newFixedThreadPool(threadQnt, debug);