From 8574a410bb667b9d9f67f492a68d3c26c3140d31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A7=A6=E8=8B=B1=E6=9D=B0?= <327782001@qq.com> Date: Tue, 7 Nov 2023 14:48:19 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E4=BC=98=E5=8C=96=E7=89=B9=E6=AE=8A?= =?UTF-8?q?=E5=9B=BE=E7=89=87=E7=9A=84=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../utils/FileContainsUtil.java | 41 ++++++++----------- 1 file changed, 17 insertions(+), 24 deletions(-) diff --git a/src/main/java/com/kwan/springbootkwan/utils/FileContainsUtil.java b/src/main/java/com/kwan/springbootkwan/utils/FileContainsUtil.java index bd14c9b..d0e44d9 100644 --- a/src/main/java/com/kwan/springbootkwan/utils/FileContainsUtil.java +++ b/src/main/java/com/kwan/springbootkwan/utils/FileContainsUtil.java @@ -49,9 +49,7 @@ public class FileContainsUtil { * 图片白名单 */ private static final List PIC_PATH_WHITELISTS = Arrays.asList( - "image-20231023195334369.png", "logo.png" - , "image-20230601124308164.png" - , "image-20230822102858692.png" + "image-20231107143410634.png" ); public static void main(String[] args) throws Exception { @@ -82,7 +80,7 @@ public class FileContainsUtil { * @param isNotExist */ private static void moreThread(List> groupedPicNames, List isNotExist) { - // 创建并启动4个线程来处理每个组的任务 + // 创建并启动6个线程来处理每个组的任务 List threads = new ArrayList<>(); for (int i = 0; i < 6; i++) { final List group = groupedPicNames.get(i); @@ -90,31 +88,26 @@ public class FileContainsUtil { // 在这里执行处理图片组的任务 if (CollectionUtil.isNotEmpty(group)) { for (String picName : group) { - // 处理图片文件 picName //是白名单里面的图片,直接忽略 - for (String picPathWhitelist : PIC_PATH_WHITELISTS) { - if (picPathWhitelist.contains(picName)) { - continue; + if (!PIC_PATH_WHITELISTS.contains(picName)) { + //默认不存在 + IS_EXIST.set(false); + //包含某个字符串 + try { + traverseFolder(BLOG_FOLDER1, picName); + traverseFolder(BLOG_FOLDER2, picName); + traverseFolder(BLOG_FOLDER3, picName); + } catch (Exception e) { + e.printStackTrace(); + } + //文件不存在 + if (!IS_EXIST.get()) { + isNotExist.add(picName); + deletePic(PIC_PATH + picName); } - } - //默认不存在 - IS_EXIST.set(false); - //包含某个字符串 - try { - traverseFolder(BLOG_FOLDER1, picName); - traverseFolder(BLOG_FOLDER2, picName); - traverseFolder(BLOG_FOLDER3, picName); - } catch (Exception e) { - e.printStackTrace(); - } - //文件不存在 - if (!IS_EXIST.get()) { - isNotExist.add(picName); - deletePic(PIC_PATH + picName); } } } - }); thread.start(); threads.add(thread); -- GitLab