From 8a95ff723d0fe23fea9360166fab13647ce1caba Mon Sep 17 00:00:00 2001 From: nntthuy-axonivy Date: Tue, 24 Dec 2024 10:22:23 +0700 Subject: [PATCH] Prevent set to DB if no index file --- .../service/impl/FileDownloadServiceImpl.java | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/marketplace-service/src/main/java/com/axonivy/market/service/impl/FileDownloadServiceImpl.java b/marketplace-service/src/main/java/com/axonivy/market/service/impl/FileDownloadServiceImpl.java index 78072bb28..c788cf314 100644 --- a/marketplace-service/src/main/java/com/axonivy/market/service/impl/FileDownloadServiceImpl.java +++ b/marketplace-service/src/main/java/com/axonivy/market/service/impl/FileDownloadServiceImpl.java @@ -20,15 +20,7 @@ import java.nio.file.attribute.FileAttribute; import java.nio.file.attribute.PosixFilePermission; import java.nio.file.attribute.PosixFilePermissions; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.Comparator; -import java.util.EnumSet; -import java.util.Enumeration; -import java.util.List; -import java.util.Set; -import java.util.UUID; +import java.util.*; import java.util.stream.Stream; import java.util.zip.ZipEntry; import java.util.zip.ZipFile; @@ -82,7 +74,8 @@ public String downloadAndUnzipFile(String url, boolean isForce) throws IOExcepti private Path createTempFileFromUrlAndExtractToLocation(String url, String location, boolean isForce) throws IOException { File cacheFolder = new File(location); - if (cacheFolder.exists() && cacheFolder.isDirectory() && !isForce) { + if (cacheFolder.exists() && cacheFolder.isDirectory() && Objects.requireNonNull( + cacheFolder.listFiles()).length > 0 && !isForce) { log.warn("Data is already in {}", location); return null; } else {