From bac678e854b2960da4df7a99532b1cf71d5b71ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A7=A6=E8=8B=B1=E6=9D=B0?= <327782001@qq.com> Date: Sat, 17 Jun 2023 09:25:05 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E4=B8=AD=E6=96=AD=E5=A4=96=E5=B1=82?= =?UTF-8?q?=E5=BE=AA=E7=8E=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../springbootkwan/utils/FileContainsUtil.java | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/kwan/springbootkwan/utils/FileContainsUtil.java b/src/main/java/com/kwan/springbootkwan/utils/FileContainsUtil.java index 676c631..939fbca 100644 --- a/src/main/java/com/kwan/springbootkwan/utils/FileContainsUtil.java +++ b/src/main/java/com/kwan/springbootkwan/utils/FileContainsUtil.java @@ -21,7 +21,7 @@ import java.util.List; */ public class FileContainsUtil { /** - * 默认不存在 + * 默认图片不存在 */ private static boolean IS_EXIST = false; /** @@ -37,9 +37,9 @@ public class FileContainsUtil { */ private static final String BLOG_FOLDER2 = "/Users/qinyingjie/Documents/idea-workspace/study/blog/"; /** - * 白名单 + * 图片白名单 */ - private static final List WHITELISTS = Arrays.asList( + private static final List PIC_PATH_WHITELISTS = Arrays.asList( "http://qinyingjie.top/blogImg/image-20230324112725149.png" , "http://qinyingjie.top/blogImg/logo.png" , "http://qinyingjie.top/blogImg/image-20230601124308164.png" @@ -54,10 +54,14 @@ public class FileContainsUtil { final List picNames = getPicName(PIC_PATH); System.out.println("图片总数为" + picNames.size()); if (CollectionUtil.isNotEmpty(picNames)) { - for (String picName : picNames) { + outerloop: + for (int i = 0; i < picNames.size(); i++) { + String picName = picNames.get(i); //是白名单里面的图片,直接忽略 - if (WHITELISTS.contains(picName)) { - continue; + for (String picPathWhitelist : PIC_PATH_WHITELISTS) { + if (picPathWhitelist.contains(picName)) { + continue outerloop; + } } //默认不存在 IS_EXIST = false; -- GitLab